Command to use restoring npm packages - npm

When I download a project from my repo with a package.json in its root, which command is the right one to use npm install or npm install restore?

The behaviour of npm install is
npm install without any argument will install all packages found in package.json in node_modules folder.
npm install <package_name> will install package_name. In your case will download restore package and will save it in node_modules folder. (https://www.npmjs.com/package/restore)

Just type:
npm i
From help:
>npm i -h
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

package.json not found during npm install --save on gitlab

I have this error when i try to do an npm install --save of a gitlab.com repo :
npm install--save git#gitlab.com:xxxxx\yyyyyy.git
npm ERR! Could not install from "gitlab.com:xxxxx\yyyyyy.git" as it does not contain a package.json file.
I tried to clone and then to link the directory :
git clone
npm link ../directory
Everything works fine.
Is someone have an idea ?
Use it this way: npm install https://github.com/xxxxxx/yyyyyy.git --save

How to install lodash.filter using npm?

I need to install lodash.filter to my Expo (React Native) project.
How should I do it using npm?
1.
npm i -g npm
npm i --save lodash.filter
npm i --save lodash.filter
I do not understand what npm i -g npm (it's updating something, but I think it will destroy my project).
$ npm i -g npm
$ npm i --save lodash
you can use second command.
npm i is the alias for the npm install and -g means gloabal
The -g or --global argument will cause npm to install the package globally rather than locally
npm install (in package directory, no arguments):
Install the dependencies in the local node_modules folder.
Just follow the command that are written in documentation it will be fine
The --save option instructed NPM to include the package inside of the dependencies section of your package.json automatically, thus saving you an additional step.

npm install result in an incomplete module, but yarn install is successful, why they behave differently?

I tried npm install and npm install --no-optional for my forked repository, and it was not installed completely: git+https://github.com/marsonmao/react-sketch#v0.4.104 (link).
After using npm install, only part of the repository was installed: there are only /node_modules and .eslintrc, karma.config.js, README.md...etc in MyProject/node_modules/react-sketch, but no /lib and /src...etc.
Then I tried yarn install and it was successful, every file in the repository was installed.
So why npm failed however yarn succeeded?
npm version: 5.5.1, yarn version: 1.3.2

how to update package.json after npm installl in a package

I'm writing a npm package, I'd like the package to update package.json file in the installed folder, say:
npm install mypackage
this installs mypackage, and also read the package.json in the folder where npm install is run, and write some entries, possible?
Thanks,
npm i -g npm-check-updates
npm-check-updates -u
npm install
or for a specific package, you may change dependency version and then
npm update --save

What is the difference between NPM -g (global) install and NPM --save

What is the difference between npm -g(global) install and npm --save?
First gulp install -g and --save first, then for other projects:
npm i gulp --save-dev Can I just use this command?
I don't know the basic difference between them?
npm -g will install packages globally (to npm cached folder), normally in AppData\Roaming\npm\node_modules if you're using Windows, while npm --save or --save-dev will install package directly to your node_modules directory in your project and add package to your packages.json for later purpose.