On windows for some reason when I run npm install
it won't install devDependencies. AFAIK it should. If I run npm install --dev
devDependencies are installed. I don't understand why npm install
doesn't install devDependencies too, but installs only dependencies. What could be the reason? How can I fix it?
Maybe something is wrong with my package.json? It is listed below if it may be helpful:
{
"name": "try-brunch",
"version": "0.1.0",
"private": "true",
"devDependencies": {
"brunch": "^2.0.4",
"cssnano-brunch": "^1.1.5",
"javascript-brunch": "^1.8.0",
"sass-brunch": "^1.9.2",
"uglify-js-brunch": "^1.7.8"
},
"dependencies": {
"jquery": "^2.1.4"
}
}
You can use the short way for installation dependencies only for development as follows:
npm i -D <dependencies-names>
I had a similar problem. npm install --only=dev
didn't work, and neither did npm rebuild
. Ultimately, I had to delete node_modules
and package-lock.json
and run npm install
again. That fixed it for me.
Check if npm config production value is set to true. If this value is true, it will skip over the dev dependencies.
Run npm config get production
To set it: npm config set -g production false
make sure you don't have env variable NODE_ENV
set to 'production'.
If you do, dev dependencies will not be installed without the --dev
flag
I had a package-lock.json
file from an old version of my package.json, I deleted that and then everything installed correctly.
Got a similar error after running npm-check-updates -u
. Solved it by removing node_modules
folder and package-lock.json
. After that a new npm install
and everything worked.
My exception:
Failed to load parser '@typescript-eslint/parser' declared in 'package.json ยป eslint-config-react-app#overrides[0]': Cannot find module '@typescript-eslint/parser'
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)
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
Make sure your package.json
is valid...
I had the following error...
npm WARN Invalid name: "blah blah blah"
and that, similarly, caused devDependencies
not to be installed.
FYI, changing the package.json
"name" to blah-blah-blah
fixed it.
Source: Stackoverflow.com