React modules installation fails - javascript

I'm trying to install sass-loader and node-sass via both yarn and npm , but getting the same errors .
I tried using one of these:
yarn add sass-loader#6.0.6 node-sass#4.5.3
npm install sass-loader#6.0.6 node-sass#4.5.3
But both produce similar errors. This is the response from yarn :
EDIT: I'm using windows. After setting the path of python this is the response I get:
[3/4] Linking dependencies...
warning " > react-modal#2.2.2" has incorrect peer dependency "react#^0.14.0 || ^
15.0.0".
warning " > react-modal#2.2.2" has incorrect peer dependency "react-dom#^0.14.0
|| ^15.0.0".
[4/4] Building fresh packages...
[-/2] ? waiting...
error C:\Users\sagil\Desktop\ReactTutorial\indecision-app\node_modules\node-sass
: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: C:\Users\sagil\Desktop\ReactTutorial\indecision-app\node_modules\node
-sass
Output:
Building: C:\Program Files\nodejs\node.exe C:\Users\sagil\Desktop\ReactTutorial\
indecision-app\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass
_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_m
odules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.8.0
gyp info using node#10.7.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Users\sagil\Desktop\ReactTut
orial\indecision-app\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:158:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Users\sagil\Desktop\ReactTut
orial\indecision-app\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\sagil\Desktop\ReactTutorial\indecisio
n-app\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\sagil\Desktop\ReactTutorial\indecision-a
pp\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:158:21)
gyp verb `which` failed stack:
gyp verb `which` failed 'Error: not found: python2\n at getNotFoundError (
C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_modules\\which\\w
hich.js:13:12)\n at F (C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-a
pp\\node_modules\\which\\which.js:68:19)\n at E (C:\\Users\\sagil\\Desktop\\R
eactTutorial\\indecision-app\\node_modules\\which\\which.js:80:29)\n at C:\\U
sers\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_modules\\which\\which.
js:89:16\n at C:\\Users\\sagil\\Desktop\\ReactTutorial\\indecision-app\\node_
modules\\isexe\\index.js:42:5\n at C:\\Users\\sagil\\Desktop\\ReactTutorial\\
indecision-app\\node_modules\\isexe\\windows.js:36:5\n at FSReqWrap.oncomplet
e (fs.js:158:21)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Python27\python.EXE
gyp verb check python version `C:\Python27\python.EXE -c "import sys; print "2.7
.13
gyp verb check python version .%s.%s" % sys.version_info[:3];"` returned: %j
gyp verb get node dir no --target version specified, falling back to host node v
ersion: 10.7.0
gyp verb command install [ '10.7.0' ]
gyp verb install input version string "10.7.0"
gyp verb install installing version: 10.7.0
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 10.7.0
gyp verb ensuring nodedir is created C:\Users\sagil\.node-gyp\10.7.0
gyp verb created nodedir C:\Users\sagil\.node-gyp\10.7.0
gyp http GET https://nodejs.org/download/release/v10.7.0/node-v10.7.0-headers.ta
r.gz
gyp WARN install got an error, rolling back install
gyp verb command remove [ '10.7.0' ]
gyp verb remove using node-gyp dir: C:\Users\sagil\.node-gyp
gyp verb remove removing target version: 10.7.0
gyp verb remove removing development files for version: 10.7.0
gyp ERR! configure error
gyp ERR! stack Error: connect ETIMEDOUT 104.20.22.46:443
gyp ERR! stack at TCPConnectWrap.afterConnect [as oncomplete] (net.js:1163:1
4)
gyp ERR! System Windows_NT 6.1.7601
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\sagil\\Deskto
p\\ReactTutorial\\indecision-app\\node_modules\\node-gyp\\bin\\node-gyp.js" "reb
uild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--l
ibsass_library="
gyp ERR! cwd C:\Users\sagil\Desktop\ReactTutorial\indecision-app\node_modules\no
de-sass
gyp ERR! node -v v10.7.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/add for documentation about this comm
I've tried downloading python 2.7 as stated in one of the errors. But the errors remains the same. I am stuck on this for 3 hours and would appreciate some help.
Could it be some permissions stuff? I don't understand why this is happening as I'm simply following a basic tutorial step by step .

It is a quite a common case that node-gyp build fails on windows.
to make the build pass, follow the steps described in the official documentation
The easiest way to make this work is by installing windows-build-tools using npm or yarn
npm install --global --production windows-build-tools
then try again to install node-sass and sass-loader
The problem can be solved too by using Bash on Ubuntu on windows

I think the error clearly states that python is not added in your environment variables or it is not even installed on the system. please resolve the python dependency and try again.
gyp verb check python checking for Python executable "python2" in the PATH

Related

I cannot run any project because of gyp error. How can I fix this: npm ERR! gyp verb cli

Whenever I run my code I always get the same error. I uninstall node and npm and reinstall. But now there is no "node_modules" and I get the same error. How can I fix it?
npm ERR! code 1
npm ERR! path /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/usr/local/bin/node',
npm ERR! gyp verb cli '/Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp#3.8.0
npm ERR! gyp info using node#16.14.2 | darwin | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /Users/bng/Desktop/deneme/12-vue-spa/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:198:21) {
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` succeeded python /Users/bng/opt/anaconda3/bin/python
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Command failed: /Users/bng/opt/anaconda3/bin/python -c import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack File "<string>", line 1
npm ERR! gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
npm ERR! gyp ERR! stack ^
npm ERR! gyp ERR! stack SyntaxError: invalid syntax
npm ERR! gyp ERR! stack
npm ERR! gyp ERR! stack at ChildProcess.exithandler (node:child_process:399:12)
npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:526:28)
npm ERR! gyp ERR! stack at maybeClose (node:internal/child_process:1092:16)
npm ERR! gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:302:5)
npm ERR! gyp ERR! System Darwin 21.4.0
npm ERR! gyp ERR! command "/usr/local/bin/node" "/Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /Users/bng/Desktop/deneme/12-vue-spa/node_modules/node-sass
npm ERR! gyp ERR! node -v v16.14.2
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/bng/.npm/_logs/2022-03-24T08_05_44_961Z-debug-0.log
There isn't node-sass and node-gyp. When I tried to install them I also got the same error. I cannot install anything.
I solved this problem by changing the node version to 14.15.1
Do not use node-sass anymore. Remove 'node-sass' in package.json. pls use 'dart-sass'.
https://www.npmjs.com/package/dart-sass (dart-sass is default now)
Please don't waste your time running the suggested command by others.
Please uninstall node.js and use the Node v14.x.
It will solve it automatically.
I got the same error and did this:
1. npm install node-sass
2. npm install
3. npm ci
4. ng serve --open (to launch the project ).
With most of the operating systems removing python2 this is a common issue for most projects. It definitely affected 4/5 of my recent projects after upgrading to current Linux/Debian Stable which removed python2.
The solution is for system to start using python3 and in order to do that you need to..
Solution/Solved is:
node-sass is actually at fault. Python2 is required until version 6.0.0. Normally you would upgrade to latest 7.0.3 but node-sass is currently obsolete, so we will swap to sass project.
yarn remove node-sass
yarn add sass
I've given more details on reasoning why here, or alternative dart-sass if you use "render() and renderSync() functions".:
Solved-ERR!gyp-info-using-node-gyp-3.8.0-gyp-verb-which-failed-Error-not-found-python2
Affected:
node.js /react web apps
Elixir/Phoenix assets
Android apps
Vue.js projects
The following solution works for me.
Try:
npm cache clean --force
npm uninstall node-sass
Uninstall node modules from your project
npm i sass --save
!important
i run into the same issue. ANd What I recomend to you is to install nvm to control your node version instead of unistalling the current version causing other problems with the existent projects.
NVM Installation Guide
https://www.geeksforgeeks.org/how-to-install-and-use-nvm-on-windows/
or
https://tecadmin.net/install-nvm-macos-with-homebrew/
After installation
After you are sure that you'd installed nvm successfully you can do:
nvm --version to check if nvm is successfully installed
nvm install [desired node version] ex.: nvm install 14.0.0
nvm list to check all node versions installed
nvm use [desired version] to change between node version ex.: nvm use 14.0.0
Conclusion
As I mention above, instead of unistalling your node versions you can install different versions of node and changing between then avoid future errors.
Be Happy even with bugs

Getting node-gyp and node-sass error in Ubuntu OS

Get this issue when doing npm install.
How to solve this issue in Ubuntu OS 20.04. I found some related stuff to solve it but all is related to window OS. Found nothing to solve this issue on Ubuntu OS. i also do sudo apt-get install node-gyp but it also giving some error. this is command is used to solve the issue on windows install --global windows-build-tools but not for Ubuntu OS.
npm ERR! code 1
npm ERR! path /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/bin/node /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp verb cli [
npm ERR! gyp verb cli '/usr/bin/node',
npm ERR! gyp verb cli '/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-gyp/bin/node-gyp.js',
npm ERR! gyp verb cli 'rebuild',
npm ERR! gyp verb cli '--verbose',
npm ERR! gyp verb cli '--libsass_ext=',
npm ERR! gyp verb cli '--libsass_cflags=',
npm ERR! gyp verb cli '--libsass_ldflags=',
npm ERR! gyp verb cli '--libsass_library='
npm ERR! gyp verb cli ]
npm ERR! gyp info using node-gyp#3.8.0
npm ERR! gyp info using node#15.11.0 | linux | x64
npm ERR! gyp verb command rebuild []
npm ERR! gyp verb command clean []
npm ERR! gyp verb clean removing "build" directory
npm ERR! gyp verb command configure []
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:200:21)
npm ERR! gyp verb `which` failed python2 Error: not found: python2
npm ERR! gyp verb `which` failed at getNotFoundError (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:200:21) {
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp verb check python checking for Python executable "python" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python
npm ERR! gyp verb `which` failed at getNotFoundError (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:200:21)
npm ERR! gyp verb `which` failed python Error: not found: python
npm ERR! gyp verb `which` failed at getNotFoundError (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:13:12)
npm ERR! gyp verb `which` failed at F (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:68:19)
npm ERR! gyp verb `which` failed at E (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:80:29)
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:89:16
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/index.js:42:5
npm ERR! gyp verb `which` failed at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/mode.js:8:5
npm ERR! gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:200:21) {
npm ERR! gyp verb `which` failed code: 'ENOENT'
npm ERR! gyp verb `which` failed }
npm ERR! gyp ERR! configure error
npm ERR! gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
npm ERR! gyp ERR! stack at PythonFinder.failNoPython (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-gyp/lib/configure.js:484:19)
npm ERR! gyp ERR! stack at PythonFinder.<anonymous> (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-gyp/lib/configure.js:406:16)
npm ERR! gyp ERR! stack at F (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:68:16)
npm ERR! gyp ERR! stack at E (/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:80:29)
npm ERR! gyp ERR! stack at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/which/which.js:89:16
npm ERR! gyp ERR! stack at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/index.js:42:5
npm ERR! gyp ERR! stack at /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/isexe/mode.js:8:5
npm ERR! gyp ERR! stack at FSReqCallback.oncomplete (node:fs:200:21)
npm ERR! gyp ERR! System Linux 5.8.0-44-generic
npm ERR! gyp ERR! command "/usr/bin/node" "/home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
npm ERR! gyp ERR! cwd /home/ali/Desktop/AlfaBolt/pakistanbooking_management_portal/node_modules/node-sass
npm ERR! gyp ERR! node -v v15.11.0
npm ERR! gyp ERR! node-gyp -v v3.8.0
npm ERR! gyp ERR! not ok
npm ERR! Build failed with error code: 1
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ali/.npm/_logs/2021-03-06T06_24_10_272Z-debug.log
Error message excerpt:
...
npm ERR! gyp verb check python checking for Python executable "python2" in the PATH
npm ERR! gyp verb `which` failed Error: not found: python2
...
It looks like the error is saying that python2 is required to install this package, though I'm not sure why a node module should require python2 in 2021.
Just install python2 using the standard way to install on your machine.
For example, on Ubuntu, you might install via Terminal with:
sudo apt install python2

Everytime I Try To Run NPM Install Terminal throws several errors

This is on my work laptop. I have Latest version of angular, Nodejs, Nodesass, VScode and mentioned them in Local environment path as well. If I download any Angular template from Github and Try to do NPM Install and it throws these error always. What shall I do to fix these error?
// gyp verb check python checking for Python executable "python2" in the PATH
// gyp verb `which` failed Error: not found: python2
// gyp verb `which` failed at getNotFoundError (D:\Interview\node_modules\which\which.js:13:12)
// gyp verb `which` failed at F (D:\Interview\node_modules\which\which.js:68:19)
// gyp verb `which` failed at E (D:\Interview\node_modules\which\which.js:80:29)
// gyp verb `which` failed at D:\Interview\node_modules\which\which.js:89:16
// gyp verb `which` failed at D:\Interview\node_modules\isexe\index.js:42:5
// gyp verb `which` failed at D:\Interview\node_modules\isexe\windows.js:36:5
// gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:199:21)
// gyp verb `which` failed python2 Error: not found: python2
// gyp verb `which` failed at getNotFoundError (D:\Interview\node_modules\which\which.js:13:12)
// gyp verb `which` failed at F (D:\Interview\node_modules\which\which.js:68:19)
// gyp verb `which` failed at E (D:\Interview\node_modules\which\which.js:80:29)
// gyp verb `which` failed at D:\Interview\node_modules\which\which.js:89:16
// gyp verb `which` failed at D:\Interview\node_modules\isexe\index.js:42:5
// gyp verb `which` failed at D:\Interview\node_modules\isexe\windows.js:36:5
// gyp verb `which` failed at FSReqCallback.oncomplete (node:fs:199:21) {
// gyp verb `which` failed code: 'ENOENT'
// gyp verb `which` failed }
// gyp verb check python checking for Python executable "python" in the PATH
// gyp verb `which` succeeded python C:\Program Files (x86)\Python38-32\python.EXE
// gyp ERR! configure error
// gyp ERR! stack Error: Command failed: C:\Program Files (x86)\Python38-32\python.EXE -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 (node:child_process:333:12)
// gyp ERR! stack at ChildProcess.emit (node:events:376:20)
// gyp ERR! stack at maybeClose (node:internal/child_process:1063:16)
// gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:295:5)
// gyp ERR! System Windows_NT 10.0.18363
// gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\Interview\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
// gyp ERR! cwd D:\Interview\node_modules\node-sass
// gyp ERR! node -v v15.5.1
// gyp ERR! node-gyp -v v3.8.0
// gyp ERR! not ok
// Build failed with error code: 1
// npm ERR! code ELIFECYCLE
// npm ERR! errno 1
// npm ERR! node-sass#4.14.1 postinstall: `node scripts/build.js`
// npm ERR! Exit status 1
// npm ERR!
// npm ERR! Failed at the node-sass#4.14.1 postinstall script.
// npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
I think you are using Windows for development. Some node.js modules required to build locally on a machine. so, that why it needs python version 2.x and other tools.
windows-build-tools package install required tools to build module locally. Go ahead and install this package and after installing it then try again running the command npm install command

gulp-sass error when installing

I have an error that gets thrown only when I try to install gulp-sass. I have tried installing other modules, (like gulp-livereload) and they work fine. Using npm version 6.0.0. Here is the package.json section that is requiring it:
"devDependencies": {
"gulp": "^3.9.0",
"gulp-autoprefixer": "^3.0.2",
"gulp-imagemin": "^2.3.0",
"gulp-livereload": "^3.8.0",
"gulp-sass": "^3.0.0",
"gulp-sourcemaps": "^1.5.2",
"gulp-uglifyjs": "^0.6.2",
"imagemin-pngquant": "^4.2.0"
}
The only one here that throws errors is gulp-sass. This is the error:
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli '/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.6.2
gyp info using node#6.11.2 | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:13:12)
gyp verb `which` failed at F (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:68:19)
gyp verb `which` failed at E (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:80:29)
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:89:16
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/index.js:42:5
gyp verb `which` failed at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/mode.js:8:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed stack: 'Error: not found: python2\n at getNotFoundError (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:13:12)\n at F (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:68:19)\n at E (/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:80:29)\n at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/which/which.js:89:16\n at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/index.js:42:5\n at /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/isexe/mode.js:8:5\n at FSReqWrap.oncomplete (fs.js:123:15)',
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `/usr/bin/python -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: 6.11.2
gyp verb command install [ '6.11.2' ]
gyp verb install input version string "6.11.2"
gyp verb install installing version: 6.11.2
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 6.11.2
gyp verb build dir attempting to create "build" dir: /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-sass/build'
gyp ERR! stack at Error (native)
gyp ERR! System Darwin 16.0.0
gyp ERR! command "/usr/local/bin/node" "/Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/craigbertrand/Sites/devdesktop/drupal-8/node_modules/node-sass
gyp ERR! node -v v6.11.2
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
Build failed with error code: 1
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#3.13.1 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#3.13.1 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Turns out this wasn't a permission problem. All I had to do was add the flag --unsafe-perm=true. I suppose it is a problem with the gulp-sass postinstaller itself, judging from this github post. Thanks vishwa for pointing out the permission denied error, I would have never found that post without it. ;)

Nodejs build and linking error for native c library when building IP2Location addon with node-gyp

I'm trying to use IP2Location addon for Nodejs. Normal installation using npm install ip2location to no avail. Throw error like this
sh-3.2# npm install ip2location -g --verbose
npm info it worked if it ends with ok
npm verb cli [ 'node',
npm verb cli '/usr/local/bin/npm',
npm verb cli 'install',
npm verb cli 'ip2location',
npm verb cli '-g',
npm verb cli '--verbose' ]
npm info using npm#1.3.14
npm info using node#v0.10.22
npm verb cache add [ 'ip2location', null ]
npm verb cache add name=undefined spec="ip2location" args=["ip2location",null]
npm verb parsed url { protocol: null,
npm verb parsed url slashes: null,
npm verb parsed url auth: null,
npm verb parsed url host: null,
npm verb parsed url port: null,
npm verb parsed url hostname: null,
npm verb parsed url hash: null,
npm verb parsed url search: null,
npm verb parsed url query: null,
npm verb parsed url pathname: 'ip2location',
npm verb parsed url path: 'ip2location',
npm verb parsed url href: 'ip2location' }
npm verb lock ip2location /var/root/.npm/9f287e36-ip2location.lock
npm verb addNamed [ 'ip2location', '' ]
npm verb addNamed [ null, '*' ]
npm verb lock ip2location# /var/root/.npm/10ff5e0e-ip2location.lock
npm verb url raw ip2location
npm verb url resolving [ 'https://registry.npmjs.org/', './ip2location' ]
npm verb url resolved https://registry.npmjs.org/ip2location
npm info trying registry request attempt 1 at 08:59:10
npm verb etag "B0D5VZ1AHUA0A2VRYEJBYO4E"
npm http GET https://registry.npmjs.org/ip2location
npm http 304 https://registry.npmjs.org/ip2location
npm verb etag ip2location from cache
npm verb addNamed [ 'ip2location', '0.1.2' ]
npm verb addNamed [ '0.1.2', '0.1.2' ]
npm verb lock ip2location#0.1.2 /var/root/.npm/fe0d76fc-ip2location-0-1-2.lock
npm info install ip2location#0.1.2 into /usr/local/lib
npm info installOne ip2location#0.1.2
npm info /usr/local/lib/node_modules/ip2location unbuild
npm verb tar unpack /var/root/.npm/ip2location/0.1.2/package.tgz
npm verb lock tar:///usr/local/lib/node_modules/ip2location /var/root/.npm/30456df6-cal-lib-node-modules-ip2location.lock
npm verb lock tar:///var/root/.npm/ip2location/0.1.2/package.tgz /var/root/.npm/0a77758d-pm-ip2location-0-1-2-package-tgz.lock
npm info preinstall ip2location#0.1.2
npm verb readDependencies using package.json deps
npm verb readDependencies using package.json deps
npm verb about to build /usr/local/lib/node_modules/ip2location
npm info build /usr/local/lib/node_modules/ip2location
npm verb linkStuff [ true,
npm verb linkStuff '/usr/local/lib/node_modules',
npm verb linkStuff true,
npm verb linkStuff '/usr/local/lib/node_modules' ]
npm info linkStuff ip2location#0.1.2
npm verb linkBins ip2location#0.1.2
npm verb linkMans ip2location#0.1.2
npm verb rebuildBundles ip2location#0.1.2
npm info install ip2location#0.1.2
ip2location#0.1.2 install /usr/local/lib/node_modules/ip2location
node-gyp configure build
gyp info it worked if it ends with ok
gyp verb cli [ 'node',
gyp verb cli '/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'configure',
gyp verb cli 'build' ]
gyp info using node-gyp#0.11.0
gyp info using node#0.10.22 | darwin | x64
gyp verb command configure []
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `python -c "import platform; print(platform.python_version());"` returned: "2.7.5\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.10.22
gyp verb command install [ 'v0.10.22' ]
gyp verb install input version string "v0.10.22"
gyp verb install installing version: 0.10.22
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 0.10.22
gyp verb build dir attempting to create "build" dir: /usr/local/lib/node_modules/ip2location/build
gyp verb build dir "build" dir needed to be created? /usr/local/lib/node_modules/ip2location/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /usr/local/lib/node_modules/ip2location/build/config.gypi
gyp verb config.gypi checking for gypi file: /usr/local/lib/node_modules/ip2location/config.gypi
gyp verb common.gypi checking for gypi file: /usr/local/lib/node_modules/ip2location/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/ip2location/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/npm/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/var/root/.node-gyp/0.10.22/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/var/root/.node-gyp/0.10.22',
gyp info spawn args '-Dmodule_root_dir=/usr/local/lib/node_modules/ip2location',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /var/root/.node-gyp/0.10.22
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
c++ '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/var/root/.node-gyp/0.10.22/src -I/var/root/.node-gyp/0.10.22/deps/uv/include -I/var/root/.node-gyp/0.10.22/deps/v8/include -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/ip2locationnode/src/ip2locationnode.o.d.raw -c -o Release/obj.target/ip2locationnode/src/ip2locationnode.o ../src/ip2locationnode.cc
../src/ip2locationnode.cc:3:10: fatal error: 'IP2Location.h' file not found
#include <IP2Location.h>
^
1 error generated.
make: *** [Release/obj.target/ip2locationnode/src/ip2locationnode.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:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "configure" "build"
gyp ERR! cwd /usr/local/lib/node_modules/ip2location
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.11.0
gyp ERR! not ok
npm verb unsafe-perm in lifecycle false
npm info ip2location#0.1.2 Failed to exec install script
npm info /usr/local/lib/node_modules/ip2location unbuild
npm info preuninstall ip2location#0.1.2
npm info uninstall ip2location#0.1.2
npm verb true,/usr/local/lib/node_modules,/usr/local/lib/node_modules unbuild ip2location#0.1.2
npm info postuninstall ip2location#0.1.2
npm ERR! ip2location#0.1.2 install: `node-gyp configure build`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the ip2location#0.1.2 install script.
npm ERR! This is most likely a problem with the ip2location package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! node-gyp configure build
npm ERR! You can get their info via:
npm ERR! npm owner ls ip2location
npm ERR! There is likely additional logging output above.
npm ERR! System Darwin 13.0.0
npm ERR! command "node" "/usr/local/bin/npm" "install" "ip2location" "-g" "--verbose"
npm ERR! cwd /
npm ERR! node -v v0.10.22
npm ERR! npm -v 1.3.14
npm ERR! code ELIFECYCLE
npm verb exit [ 1, true ]
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR! /npm-debug.log
npm ERR! not ok code 0
Based on that, I assume it require IP2Location library installed. I get the library from this
http://www.ip2location.com/developers/c and compiled that library using provided manual.
Then I downloaded the IP2Location source code, edit the binding.gyp to
{
'targets': [
{
'target_name': 'ip2locationnode',
'sources': [ 'src/ip2locationnode.cc' ],
'include_dirs': [ 'lib','lib/iMath' ],
'link_settings': {
'libraries': [
'-I/Users/mobafone/Downloads/node-ip2location-master/lib',
'-I/Users/mobafone/Downloads/node-ip2location-master/lib/iMath'
]
}
}
]
}
I tried running node-gyp configure build with this result
gyp info it worked if it ends with ok
gyp verb cli [ 'node',
gyp verb cli '/usr/local/bin/node-gyp',
gyp verb cli 'configure',
gyp verb cli 'build',
gyp verb cli '--verbose' ]
gyp info using node-gyp#0.12.1
gyp info using node#0.10.22 | darwin | x64
gyp verb command configure []
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `python -c "import platform; print(platform.python_version());"` returned: "2.7.5\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.10.22
gyp verb command install [ 'v0.10.22' ]
gyp verb install input version string "v0.10.22"
gyp verb install installing version: 0.10.22
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 0.10.22
gyp verb build dir attempting to create "build" dir: /Users/mobafone/Downloads/node-ip2location-master/build
gyp verb build dir "build" dir needed to be created? /Users/mobafone/Downloads/node-ip2location-master/build
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/mobafone/Downloads/node-ip2location-master/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/mobafone/Downloads/node-ip2location-master/config.gypi
gyp verb common.gypi checking for gypi file: /Users/mobafone/Downloads/node-ip2location-master/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/mobafone/Downloads/node-ip2location-master/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/mobafone/.node-gyp/0.10.22/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/mobafone/.node-gyp/0.10.22',
gyp info spawn args '-Dmodule_root_dir=/Users/mobafone/Downloads/node-ip2location-master',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /Users/mobafone/.node-gyp/0.10.22
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
c++ '-D_DARWIN_USE_64_BIT_INODE=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-DBUILDING_NODE_EXTENSION' -I/Users/mobafone/.node-gyp/0.10.22/src -I/Users/mobafone/.node-gyp/0.10.22/deps/uv/include -I/Users/mobafone/.node-gyp/0.10.22/deps/v8/include -I../lib -I../lib/iMath -Os -gdwarf-2 -mmacosx-version-min=10.5 -arch x86_64 -Wall -Wendif-labels -W -Wno-unused-parameter -fno-rtti -fno-exceptions -fno-threadsafe-statics -fno-strict-aliasing -MMD -MF ./Release/.deps/Release/obj.target/ip2locationnode/src/ip2locationnode.o.d.raw -c -o Release/obj.target/ip2locationnode/src/ip2locationnode.o ../src/ip2locationnode.cc
./gyp-mac-tool flock ./Release/linker.lock c++ -bundle -Wl,-search_paths_first -mmacosx-version-min=10.5 -arch x86_64 -L./Release -o Release/ip2locationnode.node Release/obj.target/ip2locationnode/src/ip2locationnode.o -undefined dynamic_lookup -I/Users/mobafone/Downloads/node-ip2location-master/lib -I/Users/mobafone/Downloads/node-ip2location-master/lib/iMath
SOLINK_MODULE(target) Release/ip2locationnode.node: Finished
gyp info ok
But when I tried to run the example.js using node example.js I got this result
dyld: lazy symbol binding failed: Symbol not found: _IP2Location_open
Referenced from: /Users/mobafone/Downloads/node-ip2location-master/build/Release/ip2locationnode.node
Expected in: dynamic lookup
dyld: Symbol not found: _IP2Location_open
Referenced from: /Users/mobafone/Downloads/node-ip2location-master/build/Release/ip2locationnode.node
Expected in: dynamic lookup
Trace/BPT trap: 5
This is the otool -L build/Release/ip2locationnode.node
/usr/lib/libstdc++.6.dylib (compatibility version 7.0.0, current version 60.0.0)
/usr/lib/libSystem.B.dylib (compatibility version 1.0.0, current version 1197.1.1)
/usr/lib/libgcc_s.1.dylib (compatibility version 1.0.0, current version 2577.0.0)
What went wrong?
updates:
I recompile IP2Location with make and sudo make install and put
DYLD_LIBRARY_PATH=/usr/local/lib/
new result from node-gyp configure build
gyp info it worked if it ends with ok
gyp verb cli [ 'node',
gyp verb cli '/usr/local/bin/node-gyp',
gyp verb cli 'configure',
gyp verb cli 'build',
gyp verb cli '--verbose' ]
gyp info using node-gyp#0.12.1
gyp info using node#0.10.22 | darwin | x64
gyp verb command configure []
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /usr/bin/python
gyp verb check python version `python -c "import platform; print(platform.python_version());"` returned: "2.7.5\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.10.22
gyp verb command install [ 'v0.10.22' ]
gyp verb install input version string "v0.10.22"
gyp verb install installing version: 0.10.22
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version is already installed, need to check "installVersion"
gyp verb got "installVersion" 9
gyp verb needs "installVersion" 9
gyp verb install version is good
gyp verb get node dir target node version installed: 0.10.22
gyp verb build dir attempting to create "build" dir: /Users/mobafone/Downloads/node-ip2location-master/build
gyp verb build dir "build" dir needed to be created? null
gyp verb build/config.gypi creating config file
gyp verb build/config.gypi writing out config file: /Users/mobafone/Downloads/node-ip2location-master/build/config.gypi
gyp verb config.gypi checking for gypi file: /Users/mobafone/Downloads/node-ip2location-master/config.gypi
gyp verb common.gypi checking for gypi file: /Users/mobafone/Downloads/node-ip2location-master/common.gypi
gyp verb gyp gyp format was not specified; forcing "make"
gyp info spawn python
gyp info spawn args [ '/usr/local/lib/node_modules/node-gyp/gyp/gyp_main.py',
gyp info spawn args 'binding.gyp',
gyp info spawn args '-f',
gyp info spawn args 'make',
gyp info spawn args '-I',
gyp info spawn args '/Users/mobafone/Downloads/node-ip2location-master/build/config.gypi',
gyp info spawn args '-I',
gyp info spawn args '/usr/local/lib/node_modules/node-gyp/addon.gypi',
gyp info spawn args '-I',
gyp info spawn args '/Users/mobafone/.node-gyp/0.10.22/common.gypi',
gyp info spawn args '-Dlibrary=shared_library',
gyp info spawn args '-Dvisibility=default',
gyp info spawn args '-Dnode_root_dir=/Users/mobafone/.node-gyp/0.10.22',
gyp info spawn args '-Dmodule_root_dir=/Users/mobafone/Downloads/node-ip2location-master',
gyp info spawn args '--depth=.',
gyp info spawn args '--generator-output',
gyp info spawn args 'build',
gyp info spawn args '-Goutput_dir=.' ]
gyp verb command build []
gyp verb build type Release
gyp verb architecture x64
gyp verb node dev dir /Users/mobafone/.node-gyp/0.10.22
gyp verb `which` succeeded for `make` /usr/bin/make
gyp info spawn make
gyp info spawn args [ 'V=1', 'BUILDTYPE=Release', '-C', 'build' ]
./gyp-mac-tool flock ./Release/linker.lock c++ -bundle -Wl,-search_paths_first -mmacosx-version-min=10.5 -arch x86_64 -L./Release -o Release/ip2locationnode.node Release/obj.target/ip2locationnode/src/ip2locationnode.o -undefined dynamic_lookup -lIP2Location
ld: can't link with bundle (MH_BUNDLE) only dylibs (MH_DYLIB) file '/usr/local/lib/libIP2Location.so' for architecture x86_64
clang: error: linker command failed with exit code 1 (use -v to see invocation)
make: *** [Release/ip2locationnode.node] 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/node-gyp/lib/build.js:267:23)
gyp ERR! stack at ChildProcess.EventEmitter.emit (events.js:98:17)
gyp ERR! stack at Process.ChildProcess._handle.onexit (child_process.js:789:12)
gyp ERR! System Darwin 13.0.0
gyp ERR! command "node" "/usr/local/bin/node-gyp" "configure" "build" "--verbose"
gyp ERR! cwd /Users/mobafone/Downloads/node-ip2location-master
gyp ERR! node -v v0.10.22
gyp ERR! node-gyp -v v0.12.1
gyp ERR! not ok
I am not using IP2Location nodejs package since I'm dealing with legacy code. Rewriting it would require some effort compared to installing and configuring the addon. I don't have any issue compiling it in linux based package, but since the developer machine is Mac OSX Mavericks, it severely limit what I can do with it.
Have you tried this one instead?
The IP2Location one is actually https://npmjs.org/package/ip2location-nodejs

Categories

Resources