How does the package_json know when to load devDependencies vs normal dependencies? How can it tell when you're running locally vs. in production?
Asked
Active
Viewed 917 times
3
-
1Possible duplicate of [What's the difference between dependencies, devDependencies and peerDependencies in npm package.json file?](https://stackoverflow.com/questions/18875674/whats-the-difference-between-dependencies-devdependencies-and-peerdependencies) – DarthJDG Aug 17 '17 at 07:43
1 Answers
2
by default you are in development mode when you run something like npm install
. you need to add --production
to switch.
So if you want to install only dependencies
and don't install devDependencies
you simply can use npm install --production

qiAlex
- 4,290
- 2
- 19
- 35
-
Say when you deploy to production, how does it know then to not run the devDependencies? – stackjlei Aug 17 '17 at 08:22
-
deploy - is not the base npm functionality. It is just convenience that we call our deploy process exactly deploy. And you should manually configure your webbuilder (webpack, gulp etc) to cut devDependencies. In many popular frameworks it is already configured and you don't need to worry about it – qiAlex Aug 17 '17 at 10:42