why sometimes npm install is not working on mac? - node.js

I have created nodejs project when i am running command npm install it is failing with some error
The same project is working on ubuntu system but when i clone this code on mac system and try to run npm install it failed with some error
I think there is something with scrypt module but i do't know the reason exactly
Please help me, Thanks in advance
OS: MAC
Node: 10.15
Npm :6.0
See error below :-
WareWolf:mynodeapp$ npm install
> scrypt#6.0.3 preinstall /node_modules/scrypt
> node node-scrypt-preinstall.js
Error: Error: Command failed: ./configure
configure: error: /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 /node_modules/scrypt
> node-gyp rebuild
gyp ERR! build error
gyp ERR! stack Error: `make` failed with exit code: 1
gyp ERR! stack at ChildProcess.onExit (/usr/local/Cellar/nvm/0.34.0/versions/node/v10.15.0/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:240:12)
gyp ERR! System Darwin 17.7.0
gyp ERR! command "/usr/local/Cellar/nvm/0.34.0/versions/node/v10.15.0/bin/node" "/usr/local/Cellar/nvm/0.34.0/versions/node/v10.15.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /node_modules/scrypt
gyp ERR! node -v v10.15.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
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.

You will need to remove package-lock.json, .npm and node_modules folder.
Required steps:
npm install npm#latest -g
npm cache clean — force
rm -rf ~/.npm
rm -rf node_modules
rm -f package-lock.json
In npm install .staging issue, When you run npm install, it creates the node_modules folder but all the modules go into a subfolder called .staging

I have found the same issue when I started a project in my linux machine and I like to clone to work on it from a Mac.
Solution working for me:
npm install --no-optional
More info: https://stackoverflow.com/a/47071650/2976796
The other way to solve this, is to remove the package-lock.json.

Related

I want to install mechanic on npm, I tried to run this line sudo npm install -g mechanic, but it gives me error, I don't understand this error

I want to install mechanic on my nginx server.
I got this error when I execute sudo npm install -g mechanic:
tigaron#galaxybrainpower:/var/www/tigaron$ sudo npm install -g mechanic
/usr/bin/mechanic -> /usr/lib/node_modules/mechanic/bin/mechanic
> fs-ext#2.0.0 install /usr/lib/node_modules/mechanic/node_modules/fs-ext
> node-gyp configure build
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/home/tigaron/.cache/node-gyp/10.20.1"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/lib/node_modules/mechanic/node_modules/fs-ext/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/mechanic/node_modules/fs-ext/.node-gyp'
gyp ERR! System Linux 4.15.0
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/lib/node_modules/mechanic/node_modules/fs-ext
gyp ERR! node -v v10.20.1
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fs-ext#2.0.0 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fs-ext#2.0.0 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! /home/tigaron/.npm/_logs/2020-05-24T06_29_26_857Z-debug.log
What is happening here? How to fix this error and proceed with the installation?
This answer solved the same issue I had when installing a different package.
Apparently the nobody user is used when building packages globally, but the directories are owned by root so it fails permissions. Configuring npm to use root with the following command is what the answer recommends.
npm -g config set user root

npm install error, is node-gyp mojave problem?

I can't resolve this error !! I'm getting crazy:
Here is the error:
gyp ERR! stack Error: Can't find Python executable "/path/to/python27/python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! stack at F (/usr/local/lib/node_modules/npm/node_modules/which/which.js:68:16)
gyp ERR! stack at E (/usr/local/lib/node_modules/npm/node_modules/which/which.js:80:29)
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/which/which.js:89:16
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/isexe/index.js:42:5
gyp ERR! stack at /usr/local/lib/node_modules/npm/node_modules/isexe/mode.js:8:5
gyp ERR! stack at FSReqCallback.oncomplete (fs.js:149:21)
gyp ERR! System Darwin 18.6.0
gyp ERR! command "/usr/local/Cellar/node/12.3.1/bin/node" "/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /Users/federicofrydman/Desktop/glamitGitHub/front-quiz/node_modules/fibers
gyp ERR! node -v v12.3.1
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
node-gyp exited with code: 1
This was suggested:
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: sudo apt-get install g++ build-essential
RHEL users please run: yum install gcc-c++ and yum groupinstall 'Development Tools'
Alpine users please run: sudo apk add python make g++
sh: nodejs: command not found
npm WARN ts-pnp#1.1.2 requires a peer of typescript#* but none is installed. You must install peer dependencies yourself.
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! fibers#3.1.1 install: `node build.js || nodejs build.js`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the fibers#3.1.1 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/federicofrydman/.npm/_logs/2019-07-02T03_47_12_405Z-debug.log
Using the following tools:
1.MOJAVE 10.14.5
2.XCODE 10.2.1
3.PYTHON 2.7
Issue seems to be with fibers#3.1.1 which is not supported in node version 12.
Fix it by removing my latest nodejs, 12.3.1, and installing the previous stable version of 11.
https://nodejs.org/download/release/v11.15.0/

NPM / Nodejs: Can't install scrypt#6.0.3

Actually I am trying to install express-basic-auth, but it fails due to the installation of scrypt#6.0.3. I already tried:
sudo apt-get install build-essential
and also tried deleting ~/.node-gyp as stated here: https://github.com/nodejs/node-gyp/issues/809, but none of the suggestions helped. I still get the same error:
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/user/code/a/b/node_modules/scrypt/build'
gyp ERR! System Linux 4.20.0-042000-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/code/a/b/node_modules/scrypt
gyp ERR! node -v v9.11.2
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
npm WARN b#1.0.0 No repository 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! /home/user/.npm/_logs/2018-12-30T20_52_24_060Z-debug.log
Can anybody help?
I solved this problem by installing an earlier version of node locally, in my case the node 8.10.0 version. I stopped getting the same error you are getting here. Delete your node modules and package-lock.json then run
npm install --save node#earlierversion
npm install rest of packages
That's what I did to rebuild my node modules and prevent this error.

fibers#1.0.15 install node_modules/fibers node build.js || nodejs build.js

I'm have error when trying to run sudo npm install in node 10, in local server its work perfect.
error:
fibers#1.0.15 install /home/tickets/www/tickets_parser/node_modules/fibers
node build.js || nodejs build.js
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/tickets/www/tickets_parser/node_modules/fibers/build'
gyp ERR! System Linux 4.4.0-97-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /home/tickets/www/tickets_parser/node_modules/fibers
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: sudo apt-get install g++ build-essential
Alpine users please run: sudo apk add python make g++
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/tickets/www/tickets_parser/node_modules/fibers/build'
gyp ERR! System Linux 4.4.0-97-generic
gyp ERR! command "/usr/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--release"
gyp ERR! cwd /home/tickets/www/tickets_parser/node_modules/fibers
gyp ERR! node -v v10.0.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
node-gyp exited with code: 1
Please make sure you are using a supported platform and node version. If you
would like to compile fibers on this machine please make sure you have setup your
build environment--
Windows + OS X instructions here: https://github.com/nodejs/node-gyp
Ubuntu users please run: sudo apt-get install g++ build-essential
Alpine users please run: sudo apk add python make g++
npm WARN tickets_parser#0.0.0 No description
npm WARN tickets_parser#0.0.0 No repository field.
npm WARN tickets_parser#0.0.0 No license field.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fibers#1.0.15 install: node build.js || nodejs build.js
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the fibers#1.0.15 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! /home/tickets/.npm/_logs/2018-05-14T19_08_18_241Z-debug.log
thanks

npm install zmq fails

I tried npm install zmq and I got:
make: Entering directory '/home/lucas/dir/node_modules/zmq/build'
CXX(target) Release/obj.target/zmq/binding.o
../binding.cc:28:17: fatal error: zmq.h: No such file or directory
compilation terminated.
zmq.target.mk:94: recipe for target 'Release/obj.target/zmq/binding.o' failed
make: *** [Release/obj.target/zmq/binding.o] Error 1
make: Leaving directory '/home/lucas/dir/node_modules/zmq/build'
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:276:23)
gyp ERR! stack at emitTwo (events.js:106:13)
gyp ERR! stack at ChildProcess.emit (events.js:191:7)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:215:12)
gyp ERR! System Linux 4.4.0-59-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/lucas/dir/node_modules/zmq
gyp ERR! node -v v7.4.0
gyp ERR! node-gyp -v v3.4.0
gyp ERR! not ok
npm WARN projectName#1.0.0 No repository field.
npm ERR! Linux 4.4.0-59-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "zmq"
npm ERR! node v7.4.0
npm ERR! npm v4.0.5
npm ERR! code ELIFECYCLE
npm ERR! zmq#2.15.3 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the zmq#2.15.3 install script 'node-gyp rebuild'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the zmq package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp rebuild
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs zmq
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls zmq
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /home/lucas/dir/npm-debug.log
Here's the pastebin of that npm-debug.log:
http://pastebin.com/UGLDEWin
Does anybody have any idea of what's happening? Seems like error in the compilation or so. As you see, my nodejs is version 7.x, not an old one. And NPM is 4.x, should work, right?
Update on latest Ubuntu:
sudo apt-get install libtool pkg-config build-essential autoconf automake
sudo apt-get install libzmq3-dev
Try to:
sudo apt-get install build-essential checkinstall
then, relaunch npm install.
If it fails again, you can try to install node-gyp globally:
npm install -g node-gyp
installing on Unix/Mac:
First install pkg-config and the ZeroMQ library.
This module is compatible with ZeroMQ versions 2, 3 and 4. The installation process varies by platform, but headers are mandatory. Most Linux distributions provide these headers with -devel packages like zeromq-devel or zeromq3-devel. Homebrew for OS X provides versions 4 and 3 with packages zeromq and zeromq3, respectively. A Chris Lea PPA is available for Debian-like users who want a version newer than currently provided by their distribution
For windows
First install Visual Studio and either Node.js or io.js.
Ensure you're building zmq from a conservative location on disk, one without unusual characters or spaces, for example somewhere like: C:\sources\myproject.
Installing the ZeroMQ library is optional and not required on Windows. We recommend running npm install and node executable commands from a github for windows shell or similar environment.
https://www.npmjs.com/package/zmq
What worked for me to avoid the Error: `make` failed with exit code: 2 error after running sudo apt-get install libzmq3-dev along with making sure I had installed all of the packages from the other answers:
From the docs:
To use your system's libzmq (if it has been installed and development headers are available):
npm install zeromq#5 --zmq-external

Resources