I know there are other similar questions like this one but in my case it happens on production server and after running:
git pull
npm ci
Then I run:
git diff --ignore-all-space package-lock.json
There is no output indicating both files are the same. but still git status complains:
oltsm@oltsm:~/oltsm2$ git status
On branch master
Your branch is up to date with 'origin/master'.
Changes not staged for commit: (use "git add <file>..." to update what will be committed) (use "git restore <file>..." to discard changes in working directory)
modified: package-lock.json
no changes added to commit (use "git add" and/or "git commit -a")
Since I want zero changes on production server from what the repo have, is there any clean way to avoid that file being modified by npm? I mean using Node own tools/configuration. I know I could write an script that does:
git pull && npm ci && git checkout
but I am not sure if I should do that.
The only extra hint I can give is this:
My local machine has:
rudy@rudy:~/37sur/oltsm2$ npm -v
10.4.0
While production has:
oltsm@oltsm:~/oltsm2$ npm -v
10.2.1
Edit
On production:
oltsm@oltsm:~/oltsm2$ head package-lock.json
{
"name": "oltsm2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"https": "^1.0.0",
"myjsunit": "file:../myjsunit",
"mysql": "^2.18.1",
On my local machine:
rudy@rudy:~/37sur/oltsm2$ head package-lock.json
{
"name": "oltsm2",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"dependencies": {
"https": "^1.0.0",
"myjsunit": "file:../myjsunit",
"mysql": "^2.18.1",
Edit 2
After doing more digging, found this which gives me the clue that there is no easy solution for this particular problem. I do not mind using tabs, 2, 4, 8 or 9 spaces as long as is consistent among different installations.
Edit 3
Per @joanis request:
Production machine:
root@oltsm:~# uname -a
Linux oltsm 6.1.0-13-amd64 #1 SMP PREEMPT_DYNAMIC Debian 6.1.55-1
(2023-09-29) x86_64 GNU/Linux
root@oltsm:~# node -v
v20.9.0
root@oltsm:~# npm -v
10.2.1
root@oltsm:~# cat /etc/debian_version
12.5
On my local machine:
rudy@rudy:/usr/bin$ uname -a
Linux rudy.local 5.19.17 #1 SMP PREEMPT_DYNAMIC Mon Oct 24 13:00:29 CDT 2022 x86_64 Intel(R) Celeron(R) G4930 CPU @ 3.20GHz GenuineIntel GNU/Linux
rudy@rudy:/usr/bin$ node -v
v20.9.0
rudy@rudy:/usr/bin$ npm -v
10.4.0
rudy@rudy:/usr/bin$ cat /etc/slackware-version
Slackware 15.0+
I also found this comment from one of the contributors of npm.
I will try to create a minimum reproducible example.
Update
Apparently it has to do something with npm version since I made an update during the process of trying to solve it. Now it is working as intended, but I will try to create a test case with npm 1.2.0 which - I believe - triggered the problem.