Package-lock json file modified without any dependency installation when npm install executed

Viewed 113

currently I have an issue. when I run the command npm install, the package-lock.json is executed unexpected formatting.

As you can see below, the requires property is deleted after running npm install. Even no any package installation

for example from this:

 "@react-native-community/masked-view": {
      "version": "0.1.10",
      "resolved": "foo",
      "integrity": "bar",
      "requires": {}
    },

to this:

  "@react-native-community/masked-view": {
      "version": "0.1.10",
      "resolved": "foo",
      "integrity": "bar"
    },

However, this is not my wanted action, and because of it, every commit between me a colleague has difference.

I would like this auto formatting...? won't work when I run npm install

Can anyone has an idea about this issue?

This is my .npmrc

legacy-peer-deps=true

npm version: v8.4.0

node version: v14.17.0

1 Answers

You should do the next command instead:

npm ci

which does the following:

This command is similar to npm install, except it's meant to be used in automated environments such as test platforms, continuous integration, and deployment -- or any situation where you want to make sure you're doing a clean install of your dependencies (It will never write to package.json or any of the package-locks: installs are essentially frozen).

For more information look up the ci command in the npm documentation.

Related