Skip to content

NPM 11.3 update causes file not found error for platform specific dependencies #626

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

Open
Marv51 opened this issue May 5, 2025 · 0 comments
Labels
bug Something isn't working

Comments

@Marv51
Copy link

Marv51 commented May 5, 2025

Describe the bug
Packages like "esbuild" contain platform specific dependencies. Something has changed in the latest npm upgrade where these dependencies are handled differently now. This leads to them no longer being installed by default. The "missing" dependency causes generate-license-file to throw an error.

How are you using generate-license-file?
CLI

What version of generate-license-file are you using?
4.0

To Reproduce
Steps to reproduce the behavior:

My sample project looks like this:

{
  "name": "license-bug",
  "version": "1.0.0",
  "description": "",
  "license": "ISC",
  "author": "",
  "type": "commonjs",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "dependencies": {
    "esbuild": "^0.25.3",
    "generate-license-file": "^4.0.0"
  }
}

Run:

npm install -g npm@latest
npm update 
npx generate-license-file --input package.json --output Libraries.txt --overwrite --omit-versions

I get (using x64 Windows laptop):

⠙ Resolving licenses...G:\source\repos\license-bug\node_modules\generate-license-file\src\lib\utils\packageJson.utils.js:9
        throw new Error(`Cannot find the file: '${pathToPackageJson}'`);
              ^

Error: Cannot find the file: 'G:\source\repos\license-bug\node_modules\@esbuild\aix-ppc64\package.json'
    at G:\source\repos\license-bug\node_modules\generate-license-file\src\lib\utils\packageJson.utils.js:9:15
    at Generator.next (<anonymous>)
    at fulfilled (G:\source\repos\license-bug\node_modules\tslib\tslib.js:167:62)

Node.js v22.13.0

The mentioned file and directory do indeed not exist. There is no directory G:\source\repos\license-bug\node_modules\@esbuild\aix-ppc64.

When I downgrade to npm 11.2, everything works as expected.

npm install -g [email protected]
npm update 
npx generate-license-file --input package.json --output Libraries.txt --overwrite --omit-versions

Expected behavior
License file should be created an no error should be thrown.

It would be cool if generate-license-file could detect the architecture and automatically exclude packages not used for the build. (Maybe this could even be expanded to OS specific packages?)

An option to ignore missing dependencies would also solve this issue and might be easier to implement.

Screenshots
n/a

Desktop (please complete the following information):
Windows 11 - x64

Additional context
I looked at manually excluding these dependencies as a workaround, but can not get that to work. Even excluding all of esbuild "exclude": ["[email protected]"] does not work for me.

I think the npm-change responsible is npm/cli#8184 to fix this long standing npm issue: npm/cli#4828

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant