Difference betweeen npm install and npm install --save? [duplicate] - node.js

This question already has answers here:
Difference between npm install --save and npm install --save-dev
(3 answers)
What is the --save option for npm install?
(14 answers)
Closed 5 years ago.
Including of the word --save means? or What is the Difference betweeen:
npm install and npm install --save?

Base on the npm documentations:
For older versions of NPM:
The npm install <package_name> command just downloads the specified package from NPM cloud, and saves it in node_modules directory in your current directory.
The npm install <package_name> --save command downloads the specified package from NPM cloud, and saves it in node_modules directory in your current directory, and also it adds the installed package into dependencies section of your package.json file.
For NPM versions > 5, there is no difference between these two commands. That is, the first command without --save option downloads the package and adds it into dependencies section of package.json file.

Related

How can I uninstall npm version [duplicate]

This question already has answers here:
Message "npm WARN config global `--global`, `--local` are deprecated. Use `--location=global` instead"
(23 answers)
Closed 3 months ago.
My npm version is 8.11.0.
When I create react package, but it gives me a Warn.
How can I uninstall it?
npm uninstall <package_name>
To uninstall an unscoped, global package on the command line, use the uninstall command with the -g flag:
npm uninstall -g <package_name>
Locally uninstall npm package:
To uninstall a package you have previously installed locally, run following from the project root folder (the folder that contains the node_modules folder):
npm uninstall <package-name>
Note: This operation will also remove the reference in the package.json file.
If the package was a development dependency, listed in the devDependencies of the package.json file, you must use the -D / --save-dev flag to remove it from the file:
npm uninstall -D <package-name>
Globally uninstall npm package:
If the package is installed globally, you need to add the -g / --global flag:
npm uninstall -g <package-name>
You need to just write in your terminal
npm uninstall <package_name_which_you_want_to_uninstall>

Unable to install node-sass in my project [closed]

Closed. This question needs debugging details. It is not currently accepting answers.
Edit the question to include desired behavior, a specific problem or error, and the shortest code necessary to reproduce the problem. This will help others answer the question.
Closed 3 years ago.
Improve this question
I am doing wes-bos Learn Node course. When I run npm start it shows - cannot find module node-sass. And when I try to run npm install node-sass --save, it gives me the following errors.
Uninstall node-sass: npm uninstall node-sass
Delete package-lock.json, and clean the cache: npm cache clean --force, then do npm update, npm install, npm update. then again try to install node sass: npm install node-sass.
If this doesn't work, Try to rebuild node-sass:
npm rebuild node-sass
If that too doesn't work then i suggest to delete package-lock.json, node-modules and npm cache folder and do npm install , to install all your dependencies again. make sure you have a package.json file with all your dependencies listed.
The package-lock.json file has some issues(it doesn't update when package.json changes) as mentioned here:https://github.com/npm/npm/issues/16866
"Touching package.json by hand may make your package.json to be incompatible with package-lock.json". do npm update to update the package-lock.json file.
to completely disable package-lock creation:
npm config set package-lock false
Update (16 july 2022):
As node-sass is depricated(https://www.npmjs.com/package/node-sass), it is recommended to use dart-sass instead and upgrade the node version to v16 at least.
Try this
sudo npm install -g --unsafe-perm node-sass --save

How to sync the dependency of package json in npm

In my case,i use npm install moduleName -save to install a module ,but after npm notice that it is install complete,the package.json will not be add dependencies of the module;
Is there any solution to sync from module to dependencies;
Thanks at first
You need npm install moduleName --save (2 '-')
Actually you can use one -s. Here is the quote from the npm documentation:
As of version 2.0.0 you can provide a path to a local directory that
contains a package. Local paths can be saved using npm install -S or
npm install --save, using any of these forms:
So if you wanted to install lodash you could use:
npm install lodash --save
or:
npm install -S lodash

"npm install" independent of npmjs.org

npm install downloads packages from npmjs.org, compiles and then installs. So even if the node_modules folder is taken backup it can not be used on other machines where the os might be different, due to the native machine code generated during the npm install.
Also another problem with npm install is that it downloads from npmjs.org. What if the site goes down?. How to download the packages and the same package be installed offline on all platforms?
You can tell npm to use a mirror if npmjs.org is down. For example:
npm set registry http://registry.npmjs.eu/
Or with a runtime option:
npm --registry http://registry.npmjs.eu/ install express
If you do keep the node_modules directory with your code, you can simply run npm rebuild to re-compile anything that needs it.
Otherwise, you have a lot of options for installing from various locations. You could keep package tarballs locally. From the documentation:
npm install (with no args in a package dir)
npm install <tarball file>
npm install <tarball url>
npm install <folder>
npm install [#<scope>/]<name> [--save|--save-dev|--save-optional] [--save-exact]
npm install [#<scope>/]<name>#<tag>
npm install [#<scope>/]<name>#<version>
npm install [#<scope>/]<name>#<version range>
npm i (with any of the previous argument usage)

What does the --save-dev option mean in npm install? [duplicate]

This question already has answers here:
What does -save-dev mean in npm install grunt --save-dev
(8 answers)
Closed 8 years ago.
I saw this here
npm install grunt-bower-task --save-dev
What does --save-dev do? Is this the same as doing without it?
The --save option will save the package as well as the version to your packages.json file.
The --save-dev option will save the package under devDependencies which is useful when installing only development packages that you may not want to ship in production.
--Edit
Just found this. Possible duplicate: What is the --save option for npm install?

Resources