corepack icon indicating copy to clipboard operation
corepack copied to clipboard

Tools hardcoded to run scripts with npm fail when using corepack-managed npm

Open easrng opened this issue 1 year ago • 4 comments

This worked when using node-managed npm. Ideally I would be able to use npm test and npm run and such but not npm install when a package has packageManager set.

$ npm test
Usage Error: This project is configured to use pnpm

easrng avatar Jun 10 '24 10:06 easrng

Try with export COREPACK_ENABLE_STRICT=0

styfle avatar Jun 10 '24 20:06 styfle

this flag seems not working, I'm running with node v20.11.0 and corepack v0.10.0.

my issue is some dependency is running a post install script and using npm to run some command:

image

update:

this is resolved by upgrade better-sqlite3 to the latest version. I think this error message is a bit misleading, it's actually the postinstall script that failed because the version of better-sqlite3 we depend on is too old to find a pre-built binary that matches the current node version, and the post-install compilation is failing. Not an issue with npm itself.

zoubingwu avatar Jul 17 '24 10:07 zoubingwu

I made a tool that fixes this https://www.npmjs.com/package/npm-run-shim

easrng avatar Jul 17 '24 18:07 easrng

@antfu/ni will pick the correct package manager for all the package operations.

npx --package @antfu/ni nr ...

mattmess1221 avatar Oct 29 '24 13:10 mattmess1221