It does add only when I execute: npm install <package_name> --save
In the documentation though: https://docs.npmjs.com/cli/install is written this:
By default, npm install will install all modules listed as dependencies in package.json.
Which is misleading.
By default, npm install will install all modules listed as dependencies in package.json . With the --production flag (or when the NODE_ENV environment variable is set to production ), npm will not install modules listed in devDependencies .
NPM installs devDependencies within the package. json file. The 'npm install' command should add all the dependencies and devDependencies automatically during installation. If you need to add specific devDependencies to your project, you can use this command- 'npm install --save-dev'.
The Npm command not found error can appear when you install or upgrade npm. On Windows, the cause of this error could be that a PATH or system variable is not correctly set. The error can also occur if you do not have npm or Node. js installed, have an outdated version, or have permission issues.
You don't need --save anymore for NPM installs. This was long the golden standard to install a package and save it as a dependency in your project. Meaning if we didn't specify the --save flag, it would only get locally installed and not added to the package.
npm install
without arguments installs all dependencies (and dev dependencies) listed in the package.json
file.
npm install --production
installs all the dependencies (but no dev dependency)
npm install <package>
installs a package and its dependencies.
npm install <package> --save
installs a package and its dependencies, and adds it in the package.json
file.
Edit: Since npm 5, --save
is implied.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With