What "requires: true" do in package-lock.json

Our team has just upgraded to npm @ 5. package-lock.json was unified between Windows and Mac (some dependencies are not mandatory, therefore they are not installed on Windows, but they work on Mac), therefore, regardless of what is on the machine, we will generate the same node_modules structure. Everything went well, then each of the team members went through the following steps:

  • rm -rf node_modules
  • git pull
  • npm install

This is really great for all team members except one who had a modified package-lock.json after npm install . One modified line was that it removed "requires": true .

So I saw:

 { ... "version": "0.0.1", "lockfileVersion": 1, "requires": true, "dependencies": { ... } 

But he saw:

 { ... "version": "0.0.1", "lockfileVersion": 1, "dependencies": { ... } 

Does anyone know why requires: true can be removed from the package-lock.json on some machines, but not on others? Also, a little explanation of what this property does will not hurt. :)

Thanks in advance!

+7
npm npm-install
source share
1 answer

As I suspected in my comments, with 5.1.0 the requires field has been added. You can see the related stretch request here https://github.com/npm/npm/pull/17508 (view of the changes here https://github.com/npm/npm/releases/tag/v5.1.0 )

To quote what he says:

This has several fixes:

  • Here a new field package-lock.json is introduced, which is called require, which is the tracks for which the modules of this module are required.
  • .....

To avoid such a conflict, I advise you (and myself) to ensure that all members of your team use the same version of npm .

UPDATE

After upgrading npm to version 5.1.0 , I had problems with missing dependencies (working with Angular 4 application). If someone is experiencing the same problem, here is what I did to solve it:

 rm -rf node_modules npm prune npm install 

Hope this helps.

+3
source share

All Articles