npm install won't install devDependencies

前端 未结 9 1948
别跟我提以往
别跟我提以往 2020-11-28 17:34

On windows for some reason when I run npm install it won\'t install devDependencies. AFAIK it should. If I run npm install --dev <

相关标签:
9条回答
  • 2020-11-28 18:17

    So the way I got around this was in the command where i would normally run npm install or npm ci, i added NODE_ENV=build, and then NODE_ENV=production after the command, so my entire command came out to:

    RUN NODE_ENV=build && npm ci && NODE_ENV=production
    

    So far I haven't had any bad reactions, and my development dependencies which are used for building the application all worked / loaded correctly.

    I find this to be a better solution than adding an additional command like npm install --only=dev because it takes less time, and enables me to use the npm ci command, which is faster and specifically designed to be run inside CI tools / build scripts. (See npi-ci documentation for more information on it)

    0 讨论(0)
  • 2020-11-28 18:21

    I had a package-lock.json file from an old version of my package.json, I deleted that and then everything installed correctly.

    0 讨论(0)
  • 2020-11-28 18:23

    I have the same issue because I set the NODE_ENV=production while building Docker. Then I add one more npm install --only=dev. Everything works fine. I need the devDependencies for building TypeSciprt modules

    RUN npm install
    RUN npm install --only=dev
    
    0 讨论(0)
提交回复
热议问题