Reputation: 6455
I noticed that whenever I did npm install --save
, my package-lock.json
file got modified and the ^
symbol removed from the version.
For example,
"@babel/core": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.2.tgz",
"integrity": "sha512-eeD7VEZKfhK1KUXGiyPFettgF3m513f8FoBSWiQ1xTvl1RAopLs42Wp9+Ze911I6H0N9lNqJMDgoZT7gHsipeQ==",
"dev": true,
"requires": {
"@babel/code-frame": "^7.5.5",
"@babel/generator": "^7.7.2",
"@babel/helpers": "^7.7.0",
"@babel/parser": "^7.7.2",
"@babel/template": "^7.7.0",
"@babel/traverse": "^7.7.2",
"@babel/types": "^7.7.2",
"convert-source-map": "^1.7.0",
"debug": "^4.1.0",
"json5": "^2.1.0",
"lodash": "^4.17.13",
"resolve": "^1.3.2",
"semver": "^5.4.1",
"source-map": "^0.5.0"
}
changed to
"@babel/core": {
"version": "7.7.2",
"resolved": "https://registry.npmjs.org/@babel/core/-/core-7.7.2.tgz",
"integrity": "sha512-eeD7VEZKfhK1KUXGiyPFettgF3m513f8FoBSWiQ1xTvl1RAopLs42Wp9+Ze911I6H0N9lNqJMDgoZT7gHsipeQ==",
"dev": true,
"requires": {
"@babel/code-frame": "7.5.5",
"@babel/generator": "7.7.2",
"@babel/helpers": "7.7.0",
"@babel/parser": "7.7.3",
"@babel/template": "7.7.0",
"@babel/traverse": "7.7.2",
"@babel/types": "7.7.2",
"convert-source-map": "1.7.0",
"debug": "4.1.1",
"json5": "2.1.1",
"lodash": "4.17.15",
"resolve": "1.12.0",
"semver": "5.7.1",
"source-map": "0.5.7"
}
I couldn't figure out the reason why it happened like this. Understand that by providing --no-package-lock
flag would prevent modifying the existing package-lock.json
file. But is there a way to retain the ^
while still keeping package-lock.json
up-to-date?
Update: My installed npm version is 5.6.0.
Upvotes: 2
Views: 677
Reputation: 35503
The whole idea behind package-lock
file is that you will get a consistent installs no matter what environment you are installing it.
That means the installed versions must be fixed to a specific version.
Upvotes: 1