Why can I install a package with npm, but not yarn, and why does there seem to be a ghost dependency?

Viewed 184

I am using Node 12.22.10, npm 8.12.2 and yarn 3.2.1 (yarn is the package manager in use for the project).

When I try to install yarn add -D @opengsn/dev I am getting a failure:

➤ YN0000: ┌ Resolution step
➤ YN0013: │ web3-provider-engine@https://github.com/trufflesuite/provider-engine.git#commit=9694f5b4e5500651bd2ff689df8529bb5cf6b96f ca
➤ YN0013: │ web3-provider-engine@https://github.com/trufflesuite/provider-engine.git#commit=9694f5b4e5500651bd2ff689df8529bb5cf6b96f ca
➤ YN0058: │ web3-provider-engine@https://github.com/trufflesuite/provider-engine.git#commit=9694f5b4e5500651bd2ff689df8529bb5cf6b96f: Packing the package failed (exit code 1, logs can be found here: /tmp/xfs-0b17fb30/pack.log)
➤ YN0000: └ Completed in 59s 408ms
➤ YN0000: Failed with errors in 59s 409ms

The logs are extremely long, but I think the error is due to a dependency on sha3@1.2.2 which I recall from somewhere else is incompatible with newer Node versions.

I think the main error description in the logs is here:

5923 verbose stack Error: command failed
5923 verbose stack     at ChildProcess.<anonymous> (/home/azureuser/.nvm/versions/node/v12.22.10/lib/node_modules/npm/node_modules/@npmcli/promise-spawn/lib/index.js:63:27)
5923 verbose stack     at ChildProcess.emit (events.js:314:20)
5923 verbose stack     at maybeClose (internal/child_process.js:1022:16)
5923 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:287:5)
5924 verbose pkgid sha3@1.2.2
5925 verbose cwd /tmp/xfs-fef0f98c
5926 verbose Linux 5.13.0-1022-azure
5927 verbose node v12.22.10
5928 verbose npm  v8.12.2
5929 error code 1
5930 error path /tmp/xfs-fef0f98c/node_modules/sha3
5931 error command failed
5932 error command sh -c node-gyp rebuild
5933 error make: Entering directory '/tmp/xfs-fef0f98c/node_modules/sha3/build'
5933 error   CXX(target) Release/obj.target/sha3/src/addon.o
5933 error make: Leaving directory '/tmp/xfs-fef0f98c/node_modules/sha3/build'
5934 error gyp info it worked if it ends with ok
5934 error gyp info using node-gyp@9.0.0
5934 error gyp info using node@12.22.10 | linux | x64
5934 error gyp info find Python using Python version 3.10.4 found at "/usr/bin/python3"
5934 error gyp info spawn /usr/bin/python3
5934 error gyp info spawn args [
5934 error gyp info spawn args   '/home/azureuser/.nvm/versions/node/v12.22.10/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
5934 error gyp info spawn args   'binding.gyp',
5934 error gyp info spawn args   '-f',
5934 error gyp info spawn args   'make',
5934 error gyp info spawn args   '-I',
5934 error gyp info spawn args   '/tmp/xfs-fef0f98c/node_modules/sha3/build/config.gypi',
5934 error gyp info spawn args   '-I',
5934 error gyp info spawn args   '/home/azureuser/.nvm/versions/node/v12.22.10/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
5934 error gyp info spawn args   '-I',
5934 error gyp info spawn args   '/home/azureuser/.cache/node-gyp/12.22.10/include/node/common.gypi',
5934 error gyp info spawn args   '-Dlibrary=shared_library',
5934 error gyp info spawn args   '-Dvisibility=default',
5934 error gyp info spawn args   '-Dnode_root_dir=/home/azureuser/.cache/node-gyp/12.22.10',
5934 error gyp info spawn args   '-Dnode_gyp_dir=/home/azureuser/.nvm/versions/node/v12.22.10/lib/node_modules/npm/node_modules/node-gyp',
5934 error gyp info spawn args   '-Dnode_lib_file=/home/azureuser/.cache/node-gyp/12.22.10/<(target_arch)/node.lib',
5934 error gyp info spawn args   '-Dmodule_root_dir=/tmp/xfs-fef0f98c/node_modules/sha3',
5934 error gyp info spawn args   '-Dnode_engine=v8',
5934 error gyp info spawn args   '--depth=.',
5934 error gyp info spawn args   '--no-parallel',
5934 error gyp info spawn args   '--generator-output',
5934 error gyp info spawn args   'build',
5934 error gyp info spawn args   '-Goutput_dir=.'
5934 error gyp info spawn args ]
5934 error gyp info spawn make
5934 error gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]

... snipping all the compiler error detail ...

5934 error make: *** [sha3.target.mk:115: Release/obj.target/sha3/src/addon.o] Error 1
5934 error gyp ERR! build error 
5934 error gyp ERR! stack Error: `make` failed with exit code: 2
5934 error gyp ERR! stack     at ChildProcess.onExit (/home/azureuser/.nvm/versions/node/v12.22.10/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
5934 error gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
5934 error gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
5934 error gyp ERR! System Linux 5.13.0-1022-azure
5934 error gyp ERR! command "/home/azureuser/.nvm/versions/node/v12.22.10/bin/node" "/home/azureuser/.nvm/versions/node/v12.22.10/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
5934 error gyp ERR! cwd /tmp/xfs-fef0f98c/node_modules/sha3
5934 error gyp ERR! node -v v12.22.10
5934 error gyp ERR! node-gyp -v v9.0.0
5934 error gyp ERR! not ok
5935 verbose exit 1

The trouble is I can't see where the dependency is coming from. I can't run yarn why because I can't install the package, but npm-remote-ls doesn't show sha3@1.2.2 anywhere in the dependency tree.

Even more strange to me, npm install -g @opengsn/dev is successful, and again, npm ls sha3@1.2.2 doesn't show anything.

I'd love to work out how to fix this. I can't downgrade my Node version to one that is compatible with the outdated sha3 versions.

0 Answers
Related