`npm install` on bootstrapped Lisk application not working (Node v12.21.0, NPM v7.17.0)

Hi folks!

I recently ran into a new set of errors when executing npm install on a fresh project. Maybe a different set of eyes can spot an error.

Environment:

npm ERR! code 1
npm ERR! path /Users/ahprivat/Developer/learning-lisk/node_modules/lisk-commander/node_modules/lisk-framework/node_modules/sodium-native
npm ERR! command failed
npm ERR! command sh -c node-gyp rebuild
npm ERR! CC(target) Release/obj.target/sodium/binding.o
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@12.21.0 | darwin | x64
npm ERR! gyp info find Python using Python version 3.9.5 found at "/opt/homebrew/opt/python@3.9/bin/python3.9"
npm ERR! gyp info spawn /opt/homebrew/opt/python@3.9/bin/python3.9
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/usr/local/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   '/Users/ahprivat/Developer/learning-lisk/node_modules/lisk-commander/node_modules/lisk-framework/node_modules/sodium-native/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/Users/ahprivat/Library/Caches/node-gyp/12.21.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=/Users/ahprivat/Library/Caches/node-gyp/12.21.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/usr/local/lib/node_modules/npm/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/Users/ahprivat/Library/Caches/node-gyp/12.21.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/Users/ahprivat/Developer/learning-lisk/node_modules/lisk-commander/node_modules/lisk-framework/node_modules/sodium-native',
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! In file included from ../binding.c:5:
npm ERR! ../libsodium/src/libsodium/include/sodium.h:5:10: fatal error: 'sodium/version.h' file not found
npm ERR! #include "sodium/version.h"
npm ERR!          ^~~~~~~~~~~~~~~~~~
npm ERR! 1 error generated.
npm ERR! make: *** [Release/obj.target/sodium/binding.o] Error 1
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/local/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (events.js:314:20)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:276:12)
npm ERR! gyp ERR! System Darwin 20.3.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
npm ERR! gyp ERR! cwd /Users/ahprivat/Developer/learning-lisk/node_modules/lisk-commander/node_modules/lisk-framework/node_modules/sodium-native
npm ERR! gyp ERR! node -v v12.21.0
npm ERR! gyp ERR! node-gyp -v v7.1.2
npm ERR! gyp ERR! not ok

Can someone with more experience tell me what the issue is? I feel it has something to do with npm 7 since this is not the version natively shipping with Node 12… Any thoughts?

I use 12.22.1 on m1 installed through n https://github.com/tj/n
This might not have anything to do with the node version though.

What version of sdk are you talking about?

~I wonder if it’s trying to use BSD make instead of GNU make :thinking:~ nvm, this probably isn’t it

I want to report back what happened since the time I posted this. I didn’t get to the bottom of the issue but could effectively work around it by switching back and forth between the versions 6 & 7 of npm. Fortunately this only takes a few seconds using sudo npm install -g npm@latest.

1 Like