Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is it possible to not generate package-lock.json with npm 5?

Tags:

npm

I've updated npm to it's latest version recently to get the performance upgrade. But since my company hasn't updated globally, I don't want the usage of package-lock.json.

I could simply ignore it in git workflow by adding package-lock.json to my .git/info/exclude. But it would still be used by npm when installing or updating dependencies.

So how can I tell npm not to use it?

like image 955
Ulysse BN Avatar asked Jul 25 '17 17:07

Ulysse BN


2 Answers

To disable package-lock.json in a project you can add .npmrc file and content of this file will be

package-lock=false

if you try to install with npm the file will not generate.

like image 163
Mostafa Nawara Avatar answered Jan 04 '23 11:01

Mostafa Nawara


Deactivate package-lock.json usage globally

To disable it globally, you'll have to set your package-lock to false in your ~/.npmrc. You can do it by using:

npm config set package-lock false

This will allow you to use npm@5 performance without bothering with package-lock.json. Though package-lock.json has many benefits according to npm doc, and you may consider using it.

Deactivate package-lock.json usage per command

According to npm-cli doc, you can use --no-package-lock options for the install command:

npm install --no-package-lock any-lib

And according to this question, existing package-lock.json will not be taken care of.

like image 35
Ulysse BN Avatar answered Jan 04 '23 12:01

Ulysse BN