Difference between 'npm add' and 'npm install --save'? - javascript

I've searched through the web and still can't get if there is any difference between npm add <package> and npm install --save <package>.
Thanks.

npm install and add are aliases. The --save option is deprecated.
Since NPM 5, packages are saved automatically; there is no --save option.

add is just an alias for install.
So the only difference is --save, which modifies package.json with the dependancy.
$ npm add --help
npm install (with no args, in package dir)
npm install [<#scope>/]<pkg>
npm install [<#scope>/]<pkg>#<tag>
npm install [<#scope>/]<pkg>#<version>
npm install [<#scope>/]<pkg>#<version range>
npm install <folder>
npm install <tarball file>
npm install <tarball url>
npm install <git:// url>
npm install <github username>/<github project>
aliases: i, isntall, add
common options: [--save-prod|--save-dev|--save-optional] [--save-exact] [--no-save]

Related

i can't install any node packages with npm install

I try to install node packeges with nmp. When i run, it says:
up to date, audited 356 packages in 7s
found 0 vulnerabilities
I see it as a dependency in my package-json like this:
"dependencies": {
"express": "*",
"nodemon": "*"
}
but there is no node_modules was installed..
Hope someone can help.
edit: I tried the commands given in the answers but it didn't work. still same
ss from editor
These commands solve the same problem and have a look at the attached links.
https://github.com/npm/npm/issues/17282
Can't install anything using "npm install"
npm install -g npm
npm cache clean
npm update
npm install
There are a few fixes to this issue.
The first one is to install the dependencies manually, as so.
$ npm install -s express nodemon
The command should install express and nodemon at the latest versions.
The second option is to run a few commands, as so (in the order given).
$ npm install -g npm
$ npm cache clean --force
$ npm update
$ npm install
Basically, these are what the commands do (from 1-4).
This installs npm from npm (sounds weird, but there is an npm package).
This command forcefully cleans out the cache of npm.
As you can tell, npm update updates npm!
Finally, this command should be run in a directory where there is a package.json file. This installs all the dependencies listed in package.json.
Don't type out the $ in the terminal examples!

npm unable to install scrypt. node-gyp rebuild

I want to run a blockchain application, but I got this error.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt#6.0.3 install: node-gyp rebuild
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt#6.0.3 install script.
npm ERR! This is probably not a problem with npm.
There is likely additional logging output above.
I have tried deleting node_modules, npm cache verify and npm install again. I have uninstalled and reinstalled npm and nodejs. My npm version is 6.12.0 and node version v12.13.0
https://github.com/ethereum/web3.js/issues/1066#issuecomment-338841841
From this link:
I've solved this using the following steps
npm install --global --production windows-build-tools
node-gyp configure --msvs_version=2015
npm config set python /path/to/executable/python2.7
npm install web3 --save
And also, I think that you can follow steps to fix node-gyp:
https://github.com/nodejs/node-gyp
Believe or not,
use: sudo npm ...
It worked for me
I know this is an old one, but for anyone hung on this one now, what solved this for me was downgrading to node v10.24.1 & npm v6.14.12. Seems to be an issue with newer node versions.
sudo apt-get update -y
sudo apt-get remove -y gyp
sudo apt-get install -y curl bzip2 build-essential g++ python3 git make gcc gcc-multilib node-gyp
sudo apt-get install -y pkg-config xserver-xorg-dev libxext-dev pkg-config libxi-dev libglu1-mesa-dev libglew-dev
sudo npm install prebuild-install node-pre-gyp node-gyp -g
if show already exist then use --force flag while installing npm package
if then also not solve then try install package using "sudo npm i "
for more information see https://github.com/zodern/meteor-up/issues/683

-bash: ng: command not found after installing #angular/cli using npm link #angular/cli#latest

I am using:
node -v
v10.15.3
npm -v
6.4.1
I have tried below mentioned command
command: npm i -g angular/cli
Error while executing: npm ERR! /usr/local/bin/git ls-remote -h -t
ssh://git#github.com/angular/cli.git
command: npm i -g #angular/cli
npm ERR! path /Users/admin/.node_modules/bin/ng npm ERR! code EEXIST
npm ERR! Refusing to delete /Users/admin/.node_modules/bin/ng:
../lib/node_modules/angular-cli/bin/ng symlink target is not
controlled by npm
/Users/admin/.node_modules/lib/node_modules/#angular/cli npm ERR! File
exists: /Users/admin/.node_modules/bin/ng npm ERR! Move it away, and
try again.
Make sure you have the correct path in Enviroment variable -> user variable like this
In this case my npm folder are located at
C:\Users\phuc.ngo\AppData\Roaming\npm
The npm folder is where everything you install can be found like angular cli, webpack, etc...
You need to try installing angular with admin previledge and try to install it globally with -g
npm install -g #angular/cli
after installation check the angular version
ng --version

How to fix requires a peer of grunt#~0.4.0 while installing grunt plugins?

I am trying to install some Grunt plugins like grunt-contrib-clean and grunt-contrib-watch
using npm install grunt-contrib-clean --save-dev
and npm install grunt-contrib-watch --save-dev
I got these warnings:
npm WARN stellarhse#1.0.0 requires a peer of grunt#~0.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN grunt-contrib-concat#0.3.0 requires a peer of grunt#~0.4.0 but none is installed. You must install peer dependencies yourself.
npm WARN grunt-contrib-cssmin#0.10.0 requires a peer of grunt#~0.4.1 but none is installed. You must install peer dependencies yourself.
How can I fix them?
Thank you.
mostly you didn't installed grunt locally
try to install grunt locally by run this command
npm install grunt --save-dev
In case this helps anyone with a similar problem I just received this error on a successful Grunt 1.0.4 install:
grunt-contrib-concat#0.1.3 requires a peer of grunt#~0.4.0 but none is installed
and none of the above answers worked, ie:
npm update
npm install grunt-contrib-concat --save-dev
did not resolve the problem / get the latest version
The only fix was to find THE LATEST VERSION of grunt-contrib-concat on git and overwrite explicitly:
grunt-contrib-concat#1.0.1 --save-dev
I have fixed the problem,
First, Ensured that the peer dependencies section in the package.json file is empty
Second, I updated npm using
npm update
Third, install grunt cli globally using
npm install -g grunt-cli.
Finally switched to the path where the project in and complete installing grunt itself and the plugins I need and worked well.
npm install grunt --save-dev
npm install grunt-contrib-watch --save-dev
npm install grunt-contrib-clean --save-dev
Thank you.

What is the difference betweene 'npm i' and 'npm install'?

What is the difference between npm i and npm install commands? Both install all node Modules from package.json.
I know that it means to install. It could be possible that there is some difference between i and install.
There is no difference, since "npm i" is an alias for "npm install". They both do the exact same thing (install or update all the dependencies in your package-lock.json).
Docs: https://docs.npmjs.com/cli/install via CRice
npm install (aliases: npm i, npm add ) (with no args, in package dir)
npm install [<#scope>/]<name>
npm install [<#scope>/]<name>#<tag>
npm install [<#scope>/]<name>#<version>
npm install [<#scope>/]<name>#<version range>
npm install <git-host>:<git-user>/<repo-name>
npm install <git repo url>
npm install <tarball file>
npm install <tarball url>
npm install <folder>

Categories