Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm install: Use global package if it exists, rather than installing twice

When using npm install with a package.json file, how do I get it to use a globally installed package that meets the criteria instead of downloading and installing the package locally again?

I know about link, but is there a way to do what I'm describing?

like image 420
jsejcksn Avatar asked May 22 '16 04:05

jsejcksn


People also ask

What happens if you install NPM package twice?

Running npm install apart from the first time installs only the missing packages and those that need update. Save this answer. Show activity on this post. Running npm install after the first time only installs missing packages or updates existing ones.

Should you install npm packages globally?

Tip: If you are using npm 5.2 or higher, we recommend using npx to run packages globally. Installing a package globally allows you to use the code in the package as a set of tools on your local computer.

How install npm install globally?

Install Package Globally NPM can also install packages globally so that all the node. js application on that computer can import and use the installed packages. NPM installs global packages into /<User>/local/lib/node_modules folder. Apply -g in the install command to install package globally.

How use npm global package?

To install a module from npm globally, you'll simply need to use the --global flag when running the install command to have the module install globally, rather than locally (to the current directory). Note: One caveat with global modules is that, by default, npm will install them to a system directory, not a local one.


1 Answers

Yarn seems to work much better with repeated dependencies. So try yarn install instead of npm install.

like image 114
Danny Matkovsky Avatar answered Oct 21 '22 22:10

Danny Matkovsky