Describe the bug
When I try to run near-cli installed from npm on a fresh Ubuntu installation, I get the error: Error: Cannot find module 'node:crypto':
root@7f0f843debd1:/# near --help
internal/modules/cjs/loader.js:818
throw err;
^
Error: Cannot find module 'node:crypto'
Require stack:
- /usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js
- /usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/utils.js
- /usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.js
- /usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/sha512.js
- /usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/ed25519.js
- /usr/local/lib/node_modules/near-cli/node_modules/@near-js/crypto/lib/key_pair_ed25519.js
- /usr/local/lib/node_modules/near-cli/node_modules/@near-js/crypto/lib/key_pair.js
- /usr/local/lib/node_modules/near-cli/node_modules/@near-js/crypto/lib/index.js
- /usr/local/lib/node_modules/near-cli/node_modules/@near-js/keystores/lib/in_memory_key_store.js
- /usr/local/lib/node_modules/near-cli/node_modules/@near-js/keystores/lib/index.js
- /usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/key_stores/keystore.js
- /usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/key_stores/index.js
- /usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/index.js
- /usr/local/lib/node_modules/near-cli/middleware/key-store.js
- /usr/local/lib/node_modules/near-cli/bin/near-cli.js
- /usr/local/lib/node_modules/near-cli/bin/near
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
at Function.Module._load (internal/modules/cjs/loader.js:667:27)
at Module.require (internal/modules/cjs/loader.js:887:19)
at require (internal/modules/cjs/helpers.js:74:18)
at Object.<anonymous> (/usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js:8:12)
at Module._compile (internal/modules/cjs/loader.js:999:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
at Module.load (internal/modules/cjs/loader.js:863:32)
at Function.Module._load (internal/modules/cjs/loader.js:708:14)
at Module.require (internal/modules/cjs/loader.js:887:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/cryptoNode.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/utils.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/_sha2.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/node_modules/@noble/hashes/sha512.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@noble/curves/ed25519.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@near-js/crypto/lib/key_pair_ed25519.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@near-js/crypto/lib/key_pair.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@near-js/crypto/lib/index.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@near-js/keystores/lib/in_memory_key_store.js',
'/usr/local/lib/node_modules/near-cli/node_modules/@near-js/keystores/lib/index.js',
'/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/key_stores/keystore.js',
'/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/key_stores/index.js',
'/usr/local/lib/node_modules/near-cli/node_modules/near-api-js/lib/index.js',
'/usr/local/lib/node_modules/near-cli/middleware/key-store.js',
'/usr/local/lib/node_modules/near-cli/bin/near-cli.js',
'/usr/local/lib/node_modules/near-cli/bin/near'
]
}
To Reproduce
Steps to reproduce the behavior:
Get a fresh ubuntu installation (e.g ubuntu:22.04 docker image)
Ah nevermind, I didn't use nvm for the installation and that's why things broke 🤦
Installing nvm and then running npm install -g near-cli fixed the problem
Describe the bug When I try to run
near-cli
installed fromnpm
on a fresh Ubuntu installation, I get the error:Error: Cannot find module 'node:crypto'
:To Reproduce Steps to reproduce the behavior:
ubuntu:22.04
docker image)apt update
apt install npm
Install near-cli
:added 176 packages, and audited 177 packages in 7s
23 packages are looking for funding run
npm fund
for details4 moderate severity vulnerabilities
To address all issues (including breaking changes), run: npm audit fix --force
Run
npm audit
for details.Expected behavior I expected
near-cli
to work after runningnpm install
. Currently it crashes immediately, which makes it impossible to use the tool.Desktop (please complete the following information):
Additional context