solana-labs / example-helloworld

Hello world on Solana
MIT License
903 stars 870 forks source link

Install npm dependencies - npm install error #188

Closed ItFlyingStart closed 3 years ago

ItFlyingStart commented 3 years ago

I got the next error when running npm install. Can you tell how to fix this issue?

npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE   package: 'helloworld@0.0.1',
npm WARN EBADENGINE   required: { node: '12.x' },
npm WARN EBADENGINE   current: { node: 'v16.0.0', npm: '7.11.2' }
npm WARN EBADENGINE }
npm WARN deprecated @types/yaml@1.9.7: This is a stub types definition. yaml provides its own type definitions, so you do not need this installed.
npm ERR! code 1
npm ERR! path /home/ryan/Blockchains/solana-labs/example-helloworld/node_modules/secp256k1
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! make: Entering directory '/home/ryan/Blockchains/solana-labs/example-helloworld/node_modules/secp256k1/build'
npm ERR!   CC(target) Release/obj.target/secp256k1/src/secp256k1/src/secp256k1.o
npm ERR!   AR(target) Release/obj.target/secp256k1.a
npm ERR!   COPY Release/secp256k1.a
npm ERR!   CXX(target) Release/obj.target/addon/src/addon.o
npm ERR! make: Leaving directory '/home/ryan/Blockchains/solana-labs/example-helloworld/node_modules/secp256k1/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@7.1.2
npm ERR! gyp info using node@16.0.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.4 found at "/usr/bin/python3"
npm ERR! gyp WARN EACCES current user ("ryan") does not have permission to access the dev dir "/root/.cache/node-gyp/16.0.0"
npm ERR! gyp WARN EACCES attempting to reinstall using temporary dev dir "/tmp/.node-gyp"
npm ERR! (node:44353) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.
npm ERR! (Use `node --trace-deprecation ...` to show where the warning was created)
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/home/ryan/Blockchains/solana-labs/example-helloworld/node_modules/secp256k1/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/tmp/.node-gyp/16.0.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/tmp/.node-gyp/16.0.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/tmp/.node-gyp/16.0.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/home/ryan/Blockchains/solana-labs/example-helloworld/node_modules/secp256k1',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! warning: unknown warning option '-Wno-nonnull-compare' [-Wunknown-warning-option]
npm ERR! 1 warning generated.
npm ERR! make: g++: No such file or directory
npm ERR! make: *** [addon.target.mk:119: Release/obj.target/addon/src/addon.o] Error 127
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:365:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
npm ERR! gyp ERR! System Linux 5.11.0-16-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /home/ryan/Blockchains/solana-labs/example-helloworld/node_modules/secp256k1
npm ERR! gyp ERR! node -v v16.0.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

Environment Ubuntu 21.04 solana-cli 1.6.6 node v16.0.0 npm 7.11.2 rustup 1.24.1 rustc 1.51.0 cargo 1.51.0

jstarry commented 3 years ago
npm ERR! make: g++: No such file or directory
npm ERR! make: *** [addon.target.mk:119: Release/obj.target/addon/src/addon.o] Error 127

Looks like some node-gyp issue, maybe try updating? https://github.com/nodejs/node-gyp/wiki/Updating-npm%27s-bundled-node-gyp. If that doesn't work, you can open an issue here: https://github.com/cryptocoinjs/secp256k1-node

ItFlyingStart commented 3 years ago

@jstarry : thanks. I have tried your solution, but I still get the same error. I have opened a new issue: https://github.com/cryptocoinjs/secp256k1-node/issues/178 like suggested.

jstarry commented 3 years ago

Ah bummer, does it reproduce every time (even after removing node_modules)? Have you tried using node v14?

ItFlyingStart commented 3 years ago

node v14

Yes, switch to node v14 works :-). Thanks for your help.

jstarry commented 3 years ago

Ah, excellent! No problem

jstarry commented 3 years ago

added a note here: https://github.com/solana-labs/example-helloworld/commit/26e4ae160f7ae9960d9bc77e288216173bd8e93e