Skip to content

[BUG] When reinstalling, the package-lock.json is updated (local packages) #7166

Description

@dartess

Is there an existing issue for this?

  • I have searched the existing issues

This issue exists in the latest npm version

  • I am using the latest npm

Current Behavior

If you run a re-installation, changes occur in the package-lock file for a dependency from a local subdirectory - a “name” field for this dependency appears.

Expected Behavior

re-installation does not change the package-lock file:

  • the name field should appear during the first installation.
  • or the name field should not appear during re-installation.

Steps To Reproduce

  1. add local dependency in subdirectory

package.json

{
"dependencies": {
"wasm": "file:wasm/build"
}
}

wasm/build/package.json

{
"name": "wasm",
"version": "0.1.0"
}
  1. npm i

lock-file is:

{
"name": "projectname",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"wasm": "file:wasm/build"
}
},
"node_modules/wasm": {
"resolved": "wasm/build",
"link": true
},
"wasm/build": {
"version": "0.1.0"
}
}
}
  1. npm i again

now lock-file is:

{
"name": "projectname",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"wasm": "file:wasm/build"
}
},
"node_modules/wasm": {
"resolved": "wasm/build",
"link": true
},
"wasm/build": {
"name": "wasm",
"version": "0.1.0"
}
}
}

Environment

  • npm: 10.3.0
  • Node.js: v21.6.0
  • OS Name: macOS 14.2.1 (23C71)
  • System Model Name: Macbook Pro
  • npm config:
; "user" config from /Users/username/.npmrc
//registry.npmjs.org/:_authToken = (protected) auto-install-peers = true ; "project" config from /Users/username/git/projectname/.npmrcengine-strict = true ; node bin location = /usr/local/bin/node; node version = v21.6.0; npm local prefix = /Users/username/git/projectname; npm version = 10.3.0; cwd = /Users/username/git/projectname; HOME = /Users/username; Run `npm config ls -l` to show all defaults.

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions