Solve NPM errors when installing node_modules on MacOSX M1 - node-modules

When trying to install NPM modules from a VUEJS web-app I get the following errors when running
npm i
2987 error 2 warnings generated.
2987 error In file included from ../src/binding.cpp:1:
2987 error In file included from ../../nan/nan.h:56:
2987 error In file included from /Users/farhang/Library/Caches/node-gyp/16.2.0/include/node/node.h:63:
2987 error In file included from /Users/farhang/Library/Caches/node-gyp/16.2.0/include/node/v8.h:30:
2987 error /Users/farhang/Library/Caches/node-gyp/16.2.0/include/node/v8-internal.h:452:38: error: no template named 'remove_cv_t' in namespace 'std'; did you mean 'remove_cv'?
2987 error !std::is_same<Data, std::remove_cv_t<T>>::value>::Perform(data);
2987 error ~~~~~^~~~~~~~~~~
2987 error remove_cv
2987 error /Library/Developer/CommandLineTools/SDKs/MacOSX.sdk/usr/include/c++/v1/type_traits:776:50: note: 'remove_cv' declared here
2987 error template <class _Tp> struct _LIBCPP_TEMPLATE_VIS remove_cv
2987 error ^
2987 error 1 error generated.
2987 error make: *** [Release/obj.target/binding/src/binding.o] Error 1
2987 error gyp ERR! build error
2987 error gyp ERR! stack Error: `make` failed with exit code: 2
2987 error gyp ERR! stack at ChildProcess.onExit (/Users/farhang/Desktop/Covidplanner_website/covid-frontend/node_modules/node-gyp/lib/build.js:194:23)
2987 error gyp ERR! stack at ChildProcess.emit (node:events:365:28)
2987 error gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
2987 error gyp ERR! System Darwin 20.3.0
2987 error gyp ERR! command "/usr/local/bin/node" "/Users/farhang/Desktop/Covidplanner_website/covid-frontend/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
2987 error gyp ERR! cwd /Users/farhang/Desktop/Covidplanner_website/covid-frontend/node_modules/node-sass
2987 error gyp ERR! node -v v16.2.0
2987 error gyp ERR! node-gyp -v v7.1.2
2987 error gyp ERR! not ok
2987 error Build failed with error code: 1
2988 verbose exit 1
I've installed Xcode command line tools. I've tried running terminal with and without rosetta. But can't seem to find what causes this problem.

Related

Trying to install an app with node-sass on WSL. Getting "gyp ERR! stack Error: `make` failed with exit code: 2"

I was trying to install some magento storefront app that requires linux to run on WSL. I managed to get most things working, but in the end I'm stuck at trying to install the dependencies. When it tries to install node-sass, I get this error:
make: Leaving directory '/mnt/c/Github/psp-storefront-magento2/node_modules/node-sass/build'
make: *** [binding.target.mk:133: Release/obj.target/binding/src/binding.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/mnt/c/Github/psp-storefront-magento2/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (node:events:390:28)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:290:12)
gyp ERR! System Linux 4.4.0-19041-Microsoft
gyp ERR! command "/home/lursmani/.nvm/versions/node/v16.10.0/bin/node" "/mnt/c/Github/psp-storefront-magento2/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /mnt/c/Github/psp-storefront-magento2/node_modules/node-sass
gyp ERR! node -v v16.10.0
I read that deleting yarn.lock and installing again should fix this, but it hasn't helped in my case. Would greatly appreciate some help with this, if anyone knows what's funky here.
I found the solution. Apparently GYP has issues with the latest version of Node (16). I had to downgrade to Node 14 and then it worked correctly.

Can't install web3 on macos

I'm having difficulties installing web3 on my mac. I've tried a number of fixes but I get the same error every time.
I tried installing sha3 separately and made sure that I had Xtools installed.
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/craiglou/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:294:12)
gyp ERR! stack at ChildProcess.emit (events.js:189:13)
gyp ERR! stack at maybeClose (internal/child_process.js:970:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:389:11)
gyp ERR! stack at Socket.emit (events.js:189:13)
gyp ERR! stack at Pipe._handle.close (net.js:597:12)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Users/craiglou/Desktop/inbox/node_modules/keccakjs/node_modules/sha3
gyp ERR! node -v v10.15.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN webpack-cli#2.1.5 requires a peer of webpack#^4.0.0 but none is installed. You must install peer dependencies yourself.
npm WARN inbox#1.0.0 No description
npm WARN inbox#1.0.0 No repository field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3#1.2.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3#1.2.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/craiglou/.npm/_logs/2019-08-19T23_31_04_618Z-debug.log

configure: error: C compiler cannot create executables mac

I am trying to install ccxt on my Macbook Air using sudo npm install --save ccxt and encountered the following error:
> scrypt#6.0.3 preinstall /Applications/Xcode.app/Contents/Developer/Toolchains/node_modules/scrypt
> node node-scrypt-preinstall.js
Error: Error: Command failed: ./configure
configure: error: in `/Applications/Xcode.app/Contents/Developer/Toolchains/node_modules/scrypt/scrypt/scrypt-1.2.0':
configure: error: C compiler cannot create executables
See `config.log' for more details
> scrypt#6.0.3 install /Applications/Xcode.app/Contents/Developer/Toolchains/node_modules/scrypt
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /Users/peterpham/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
gyp ERR! stack ^
gyp ERR! stack SyntaxError: invalid syntax
gyp ERR! stack
gyp ERR! stack at ChildProcess.exithandler (child_process.js:275:12)
gyp ERR! stack at emitTwo (events.js:126:13)
gyp ERR! stack at ChildProcess.emit (events.js:214:7)
gyp ERR! stack at maybeClose (internal/child_process.js:925:16)
gyp ERR! stack at Socket.stream.socket.on (internal/child_process.js:346:11)
gyp ERR! stack at emitOne (events.js:116:13)
gyp ERR! stack at Socket.emit (events.js:211:7)
gyp ERR! stack at Pipe._handle.close [as _onclose] (net.js:557:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /Applications/Xcode.app/Contents/Developer/Toolchains/node_modules/scrypt
gyp ERR! node -v v8.11.3
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN enoent ENOENT: no such file or directory, open '/Applications/Xcode.app/Contents/Developer/Toolchains/package.json'
npm WARN Toolchains No description
npm WARN Toolchains No repository field.
npm WARN Toolchains No README data
npm WARN Toolchains No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! scrypt#6.0.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the scrypt#6.0.3 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/peterpham/.npm/_logs/2018-08-30T04_34_20_141Z-debug.log
I have Xcode 9.4.1 installed and checked that my command line tools were installed in the Preferences > Location section like in this other stackoverflow question. I also tried out all of the following answers in my terminal to change directories and ownerships to no avail. Also tried just sudo npm install --save scrypt with the same error. It has possibly something to do with the anaconda env pathing.
I'm pretty sure it has to do with some configuration but I'm not sure what it is. If you need anymore information please tell me and I'll post it. I don't know where the configure.log is so I can't post it, I've tried to find it using resources online as well and am lost.
The key to solving the error was this part of the error code:
gyp ERR! stack Error: Command failed: /Users/peterpham/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
So I tried installing python 2.7, which didn't work. So I tried uninstalling Anaconda from my computer using App Cleaner and that did the trick. Afterwards I could run the command npm install --save ccxt!

Unable to npm i x509 on osx

So I don't seem to be able to install the x509 package on Mac osx.
my-air:temp me$ node -v
v10.0.0
my-air:temp me$ npm -v
6.3.0
my-air:temp me$ npm i x509
> x509#0.3.3 install /Users/me/workspace/temp/node_modules/x509
> node-gyp rebuild
CXX(target) Release/obj.target/x509/src/addon.o
In file included from ../src/addon.cc:5:
In file included from ../include/x509.h:7:
In file included from ../../nan/nan.h:194:
../../nan/nan_maybe_43_inl.h:88:15: error: no member named 'ForceSet' in 'v8::Object'
return obj->ForceSet(GetCurrentContext(), key, value, attribs);
...
4 warnings and 7 errors generated.
make: *** [Release/obj.target/x509/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit
(/usr/local/lib/node_modules/npm/node_modules/node-
gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:182:13)
gyp ERR! stack at Process.ChildProcess._handle.onexit
(internal/child_process.js:225:12)
gyp ERR! System Darwin 17.6.0
gyp ERR! command "/usr/local/Cellar/node/7.0.0/bin/node"
"/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js"
"rebuild"
gyp ERR! cwd /Users/me/workspace/temp/node_modules/x509
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.7.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! x509#0.3.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the x509#0.3.3 install script.
Any help would be greatly appreciated. Am I missing a c compiler or something?

Compiling Error with sha3 & Ethereum Mist

Unhandled rejection Error: Error: npm exited with code 1
Output:
> sha3#1.2.0 install /home/user/mist/dist_mist/app/node_modules/sha3
> node-gyp rebuild
make: Entering directory '/home/user/mist/dist_mist/app/node_modules/sha3/build'
CXX(target) Release/obj.target/sha3/src/addon.o
sha3.target.mk:96: recipe for target 'Release/obj.target/sha3/src/addon.o' failed
make: Leaving directory '/home/user/mist/dist_mist/app/node_modules/sha3/build'
Error output:
In file included from /usr/include/stdint.h:25:0,
from /usr/lib/gcc/x86_64-linux-gnu/5/include/stdint.h:9,
from /home/user/.electron-gyp/.node-gyp/iojs-1.4.15/deps/v8/include/v8.h:19,
from /home/user/.electron-gyp/.node-gyp/iojs-1.4.15/src/node.h:42,
from ../src/addon.cpp:1:
/usr/include/features.h:367:25: fatal error: sys/cdefs.h: No such file or directory
compilation terminated.
make: *** [Release/obj.target/sha3/src/addon.o] Error 1
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/usr/lib/node_modules/npm/node_modules/node-gyp/lib/build.js:258:23)
gyp ERR! stack at emitTwo (events.js:125:13)
gyp ERR! stack at ChildProcess.emit (events.js:213:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:200:12)
gyp ERR! System Linux 4.10.0-28-generic
gyp ERR! command "/usr/bin/nodejs" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/mist/dist_mist/app/node_modules/sha3
gyp ERR! node -v v8.2.1
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! sha3#1.2.0 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the sha3#1.2.0 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
On Ubuntu 16.04:
I am getting this error after running gulp --linux in ~/mist.
I've tried researching for sha3 errors, I find similar posts, but cannot find a solution.
What do I do to fix? Thanks.
Faced the same problem when trying to install a truffle box. There is an issue with installing the sha3 dependency.
Somehow using a specific version of nvm solves the problem.
$ nvm install 10.16.0
$ nvm alias default 10.16.0
type in : npm install sha3 and then sudo yarn
that will work for

Resources