Description
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
When running npm install
, the package-lock.json
output is double-spaced when a blank line exists between the opening brace and the first key of package.json
.
This package.json
produces a double-spaced lockfile:
{
"name": "test-doublespace",
"dependencies": {
"left-pad": "latest"
}
}
and this one doesn't:
{
"name": "test-doublespace",
"dependencies": {
"left-pad": "latest"
}
}
The double-spaced lockfile looks like this all the way to the end:
{
"name": "test-doublespace",
"lockfileVersion": 2,
"requires": true,
"packages": {
<snip>
I've tried putting blank lines in other places, but have only been able to reproduce it with a blank line after the opening brace.
Expected Behavior
Blank lines are valid in JSON and are not considered to be "data", so I would expect any blank lines to have no impact on the locked data.
Steps To Reproduce
- Create a new empty directory
- Create a test `package.json
echo '{ "name": "test-doublespace", "dependencies": { "left-pad": "latest" } }' > package.json
- Run
npm install
- View
package-lock.json
. It should be double-spaced!
Environment
- npm: 8.19.2
- Node.js: v16.17.1
- OS Name: Ubuntu 20.04
- System Model Name: Lemur Pro
- npm config:
; "user" config from /home/mfisher/.npmrc
//registry.npmjs.org/:_authToken = (protected)
; node bin location = /home/mfisher/.nvm/versions/node/v16.17.1/bin/node
; node version = v16.17.1
; npm local prefix = /tmp/foo
; npm version = 8.19.2
; cwd = /tmp/foo
; HOME = /home/mfisher
; Run `npm config ls -l` to show all defaults.