rogeriochaves / npm-force-resolutions

Force npm to install a specific transitive dependency version
567 stars 28 forks source link

npm-force-resolutions fails, breaking npm i #25

Closed MadaraUchiha closed 3 years ago

MadaraUchiha commented 3 years ago

Running npx npm-force-resolutions always fails, whether it's in dev dependencies or not, whether I have resolutions or not, whether I have dependencies at all or not.

OS: Mac Node version: 12.13.1

Example package.json (default npm init + preinstall script):

{
  "name": "npm-force-resolution-bug",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "scripts": {
    "preinstall": "npx npm-force-resolutions",
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

npm i output:

~/projects/npm-force-resolution-bug $ npm i

> npm-force-resolution-bug@1.0.0 preinstall /Users/madara/projects/npm-force-resolution-bug
> npx npm-force-resolutions

npx: installed 6 in 3.156s
Cannot find module '/Users/madara/.npm/_npx/35623/lib/node_modules/npm-force-resolutions/.cljs_node_repl/goog/bootstrap/nodejs.js'
Require stack:
- /Users/madara/.npm/_npx/35623/lib/node_modules/npm-force-resolutions/index.js
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! npm-force-resolution-bug@1.0.0 preinstall: `npx npm-force-resolutions`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the npm-force-resolution-bug@1.0.0 preinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm WARN Local package.json exists, but node_modules missing, did you mean to install?

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/madara/.npm/_logs/2021-02-24T09_41_06_273Z-debug.log

The mentioned debug.log:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/madara/.nvm/versions/node/v12.13.1/bin/node',
1 verbose cli   '/Users/madara/.nvm/versions/node/v12.13.1/bin/npm',
1 verbose cli   'i'
1 verbose cli ]
2 info using npm@6.14.11
3 info using node@v12.13.1
4 verbose npm-session 75914a94d272f195
5 silly install runPreinstallTopLevelLifecycles
6 silly preinstall npm-force-resolution-bug@1.0.0
7 info lifecycle npm-force-resolution-bug@1.0.0~preinstall: npm-force-resolution-bug@1.0.0
8 verbose lifecycle npm-force-resolution-bug@1.0.0~preinstall: unsafe-perm in lifecycle true
9 verbose lifecycle npm-force-resolution-bug@1.0.0~preinstall: PATH: <redacted>
11 silly lifecycle npm-force-resolution-bug@1.0.0~preinstall: Args: [ '-c', 'npx npm-force-resolutions' ]
12 silly lifecycle npm-force-resolution-bug@1.0.0~preinstall: Returned: code: 1  signal: null
13 info lifecycle npm-force-resolution-bug@1.0.0~preinstall: Failed to exec preinstall script
14 timing stage:rollbackFailedOptional Completed in 1ms
15 timing stage:runTopLevelLifecycles Completed in 3283ms
16 verbose stack Error: npm-force-resolution-bug@1.0.0 preinstall: `npx npm-force-resolutions`
16 verbose stack Exit status 1
16 verbose stack     at EventEmitter.<anonymous> (/Users/madara/.nvm/versions/node/v12.13.1/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
16 verbose stack     at EventEmitter.emit (events.js:210:5)
16 verbose stack     at ChildProcess.<anonymous> (/Users/madara/.nvm/versions/node/v12.13.1/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
16 verbose stack     at ChildProcess.emit (events.js:210:5)
16 verbose stack     at maybeClose (internal/child_process.js:1021:16)
16 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5)
17 verbose pkgid npm-force-resolution-bug@1.0.0
18 verbose cwd /Users/madara/projects/npm-force-resolution-bug
19 verbose Darwin 19.6.0
20 verbose argv "/Users/madara/.nvm/versions/node/v12.13.1/bin/node" "/Users/madara/.nvm/versions/node/v12.13.1/bin/npm" "i"
21 verbose node v12.13.1
22 verbose npm  v6.14.11
23 error code ELIFECYCLE
24 error errno 1
25 error npm-force-resolution-bug@1.0.0 preinstall: `npx npm-force-resolutions`
25 error Exit status 1
26 error Failed at the npm-force-resolution-bug@1.0.0 preinstall script.
26 error This is probably not a problem with npm. There is likely additional logging output above.
27 verbose exit [ 1, true ]
MadaraUchiha commented 3 years ago

Installing npm-force-resolutions@0.0.3 as a devDependency makes it all work again.

rogeriochaves commented 3 years ago

that should have been fixed in 0.0.5 (check #22), weird that you are still getting it. Can you try to run npx npm-force-resolutions@0.0.5 just to make sure?

MadaraUchiha commented 3 years ago

I am getting that version 0.0.5 does not exist. Although that one might be attributed to my org's artifactory/mirror.

MadaraUchiha commented 3 years ago

I've confirmed that setting the registry back to the public npm one resolves this issue. I'll hash this out with our org's artifactory keepers.

Cheers!

jurgensweere commented 3 years ago

If I use 0.0.5, I still get the same issue:

Error: Timeout trying to fetch resolutions from npm

If I force it to use 0.0.3, it works fine

MadaraUchiha commented 3 years ago

@jurgensweere That appears to be a different issue, probably best to open a new one :)

rogeriochaves commented 3 years ago

@jurgensweere this is probably related to 0.0.5 not handling private registries properly, 0.0.6 should have that fixed, please follow on #26