Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG] NPM ci seems to be broken on Azure DevOps #4660

Closed
2 tasks done
terwort opened this issue Apr 1, 2022 · 16 comments
Closed
2 tasks done

[BUG] NPM ci seems to be broken on Azure DevOps #4660

terwort opened this issue Apr 1, 2022 · 16 comments
Labels
Awaiting Information further information is requested Bug thing that needs fixing Release 8.x work is associated with a specific npm 8 release

Comments

@terwort
Copy link

terwort commented Apr 1, 2022

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 ci on Azure Devops with the node version set to 16.14.2, and npm version set to 8.5.0 we get The npm ci command can only install with an existing package-lock.json. Even though we definitely have a package-lock file.

Reverting our node version back to 16.14.0, and npm to 8.3.1 fixes the issue with no other changes required.

Expected Behavior

I would expect npm ci to complete successfully.

Steps To Reproduce

I'm not sure exactly the reproduction steps. I just noticed on our Azure Devops pipeline it fails npm ci as mentioned in the Current Behavior section.

Environment

Environment: ubuntu-20.04
Version: 20220330.0
npm: 8.5.0
node: 16.14.2

@terwort terwort added Bug thing that needs fixing Needs Triage needs review for next steps Release 8.x work is associated with a specific npm 8 release labels Apr 1, 2022
@ljharb
Copy link
Contributor

ljharb commented Apr 1, 2022

Any chance you have an env var configured with “npm” in the name, case-insensitively?

@terwort
Copy link
Author

terwort commented Apr 1, 2022

@ljharb Not that I can find. This is one of the yaml files used in our pipelines, and it fails on the npm ci step. So all its done so far is set the node version and then immediately call npm ci.

`jobs:

  • job: Job_2
    displayName: ESLint
    pool:
    vmImage: ubuntu-latest
    steps:
    • task: NodeTool@0
      inputs:
      versionSpec: "16.x"
      displayName: "Set node version"
    • task: Npm@1
      displayName: npm ci preamble-ui-hcms
      inputs:
      command: ci
      workingDir: packages/preamble-ui-hcms
      verbose: false
    • task: Npm@1
      displayName: npm ci testing
      inputs:
      command: ci
      workingDir: packages/testing
      verbose: false
    • task: Npm@1
      displayName: npm run eslint:hcms
      inputs:
      command: custom
      workingDir: packages/testing
      verbose: false
      customCommand: run eslint:hcms
    • task: PublishTestResults@2
      displayName: Jest Test Results
      condition: succeededOrFailed()
      inputs:
      testResultsFiles: junit.xml
      searchFolder: packages/testing
      failTaskOnFailedTests: true
      testRunTitle: ESLint HCMS
      `
@ljharb
Copy link
Contributor

ljharb commented Apr 1, 2022

And which CI command is failing (in which dir)?

@terwort
Copy link
Author

terwort commented Apr 1, 2022

This is the path azure devops is using /opt/hostedtoolcache/node/16.14.2/x64/bin/npm ci

@ljharb
Copy link
Contributor

ljharb commented Apr 1, 2022

No i mean, your yaml file runs npm ci multiple times, in different dirs. Which one fails?

@terwort
Copy link
Author

terwort commented Apr 1, 2022

the first one in preamble-ui-hcms. Although, it fails on about 6 of our yaml files all in different directories with their own package.json files.

@jonofoz
Copy link

jonofoz commented Apr 4, 2022

@terwort My team has been having the same issue. Today I tried npm ci --legacy-peer-deps locally, which allowed me to circumvent the issues we were having. Sticking that in the pipeline, for you it'd be something like

task: Npm@1
  displayName: [something]
  inputs:
    command: custom
    customCommand: "ci --legacy-peer-deps"
    workingDir: [something]
  [other stuff here]
  [other stuff here]
  [...]

I just did something similar and my pipelines using ci are passing now.

Try that out! Please let me know if that works for you.

@Y-LyN-10
Copy link

Y-LyN-10 commented Apr 5, 2022

We are experiencing a similar issue with GitHub Actions that could be related to this one. In our case the error is that 'npm ci' can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with 'npm install' before continuing and then there is a list of "missing" libraries from the lock file.

Such error is not true because they ARE in sync (nothing changes if I do npm install) and reverting back to Node v16.14.0 (with older NPM version) is our only solution so far. There is no error there. The worst thing is that such breaking change creeped into a patch version of Node.js.

Let me know if I should open a new issue for that or/and if I can help you to reproduce the issue.

@ljharb
Copy link
Contributor

ljharb commented Apr 5, 2022

@Y-LyN-10 are you sure you’re using the same node and npm version locally and in production?

derevnjuk added a commit to NeuraLegion/har-sdk that referenced this issue Apr 7, 2022
derevnjuk added a commit to NeuraLegion/har-sdk that referenced this issue Apr 7, 2022
pmstss pushed a commit to NeuraLegion/har-sdk that referenced this issue Apr 7, 2022
@nlf
Copy link
Contributor

nlf commented Apr 7, 2022

We are experiencing a similar issue with GitHub Actions that could be related to this one. In our case the error is that 'npm ci' can only install packages when your package.json and package-lock.json or npm-shrinkwrap.json are in sync. Please update your lock file with 'npm install' before continuing and then there is a list of "missing" libraries from the lock file.

Such error is not true because they ARE in sync (nothing changes if I do npm install) and reverting back to Node v16.14.0 (with older NPM version) is our only solution so far. There is no error there. The worst thing is that such breaking change creeped into a patch version of Node.js.

Let me know if I should open a new issue for that or/and if I can help you to reproduce the issue.

this issue you're describing is not the same as the original one, and i think #4664 will help you out

@nlf
Copy link
Contributor

nlf commented Apr 8, 2022

this is an interesting one. can you reproduce this in a public repository you can share with us? the validation steps that have brought to light issues with npm ci for other folks weren't introduced until npm@8.6.0 while you're on 8.5.0.

@lukekarrys
Copy link
Contributor

Let me know if I should open a new issue for that or/and if I can help you to reproduce the issue.

@Y-LyN-10 If you can share a public repository or reproduction that would be very helpful! Opening a new issue would be best, since it might not be the same issue, and we can look in to it. Thanks!

@lukekarrys
Copy link
Contributor

@terwort Did the suggestion from #4660 (comment) to use --legacy-peer-deps (or to use the same flags locally as you do in azure with npm ci) work in your case? We've added some documentation now to highlight this (#4666). Please let me know if you're still having issues with this!

@lukekarrys lukekarrys added Awaiting Information further information is requested and removed Needs Triage needs review for next steps labels Apr 13, 2022
@Y-LyN-10
Copy link

Sorry for the late response!

Yes, I believe our issue is different - npm ci does not work for us with lockfile ver 1. --legacy-peer-deps doesn't help. We are testing with all major LTS versions of Node.js, so we are kinda stuck to old lockfile format (re-creating it with with newer npm version via npm install solves the problem, but it's not an option for us due to other NPM issues) and all tests work fine except for Node.js >=16.14.2. Our workaround is to pin the NPM version to v8.3.1 for Node 16.x.x. After all - the purpose of these tests is to test Node, not NPM.

However, if you are still interested in that issue and believe that NPM >=8.5.0 should be compatible with old lockfiles, I can try to create a public repository to reproduce it and I will open another issue for that. Thanks!

swenson pushed a commit to hashicorp/vault-action that referenced this issue Jun 15, 2022
Node 16.14.2 thinks the `package-lock.json` is out of sync when it is
not.

npm/cli#4660
@swenson
Copy link

swenson commented Jun 15, 2022

We ran into this as well in GitHub Actions for Node 16.14.2, but reverting to 16.14.0 fixed it.

swenson pushed a commit to hashicorp/vault-action that referenced this issue Jun 15, 2022
Node 16.14.2 thinks the `package-lock.json` is out of sync when it is
not.

npm/cli#4660
bazaah added a commit to bazaah/aur-ceph that referenced this issue May 12, 2023
up the bundled node version to 16, so as to fix node-gyp errors
originating from a too-old npm version in 14.

Basically, python 3.11 removed a deprecated file open option from
python, which consequently blows up `npm ci`, preventing the build.

Issue: #12
References: npm/cli#5113
References: npm/cli#4664
References: npm/cli#4660
@wraithgar
Copy link
Member

However, if you are still interested in that issue and believe that NPM >=8.5.0 should be compatible with old lockfiles, I can try to create a public repository to reproduce it and I will open another issue for that. Thanks!

Yes npm should be fully backwardly compatible with old lockfiles. If you have a way to reproduce an error please open a new issue

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Information further information is requested Bug thing that needs fixing Release 8.x work is associated with a specific npm 8 release
8 participants