How do I install node-sass on MacOSX M1? - node.js

I have an error with node-sass when trying to do a yarn on my M1 MacBook.
I have this error :
error /Users/antoinekurka/Documents/Freelance/Projets/NL/NextLevel/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /Users/antoinekurka/Documents/Freelance/Projets/NL/NextLevel/node_modules/node-sass
Output:
Building: /opt/homebrew/Cellar/node/17.8.0/bin/node /Users/antoinekurka/Documents/Freelance/Projets/NL/NextLevel/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 [
gyp verb cli '/opt/homebrew/Cellar/node/17.8.0/bin/node',
gyp verb cli '/Users/antoinekurka/Documents/Freelance/Projets/NL/NextLevel/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 verb cli ]
gyp info using node-gyp#3.8.0
gyp info using node#17.8.0 | darwin | arm64
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 "/usr/bin/python3" in the PATH
gyp verb `which` succeeded /usr/bin/python3 /usr/bin/python3
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/bin/python3 -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:398:12)
gyp ERR! stack at ChildProcess.emit (node:events:527:28)
gyp ERR! stack at maybeClose (node:internal/child_process:1090:16)
gyp ERR! stack at Socket.<anonymous> (node:internal/child_process:449:11)
gyp ERR! stack at Socket.emit (node:events:527:28)
gyp ERR! stack at Pipe.<anonymous> (node:net:709:12)
gyp ERR! System Darwin 21.4.0
gyp ERR! command "/opt/homebrew/Cellar/node/17.8.0/bin/node" "/Users/antoinekurka/Documents/Freelance/Projets/NL/NextLevel/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/antoinekurka/Documents/Freelance/Projets/NL/NextLevel/node_modules/node-sass
gyp ERR! node -v v17.8.0
I tried to do it with node 12 & 14 too.
and in the package.json I have this :
"node-sass": "^4.11.0",
"sass-loader": "^9.0.3",
I tried different versions of node-sass but nothings work.
Everytime I try, I delete the /node_modules, package-lock.json and the yarn.lock
Do someone have any idea on how to fix this ?
Thank you

node-sass is deprecated and many people have had problems installing it with the ARM architecture. Check here for more details: https://sass-lang.com/blog/libsass-is-deprecated. If you can, use sass instead.
yarn add -D sass

I had that fixed by using python2.7.
With pyenv, you can do:
pyenv install 2.7
pyenv local 2.7

Big G is right -- stop using node-sass if you can. If you can't for some reason, there is a long discussion on potential ways to solve related issues here: yarn install failing import sys; print "%s.%s.%s" % sys.version_info[:3] invalid syntax

Related

Node-Saas error on installation on my personal project

I tried to add node-sass to my project using yarn add node-sass, but I am getting this error can anyone help
[2/4] 🚚 Fetching packages...
[3/4] 🔗 Linking dependencies...
[4/4] 🔨 Building fresh packages...
[-/7] â „ waiting...
[-/7] â „ waiting...
[7/7] â „ node-sass
[6/7] â „ pngcrush-bin
error /Users/user/Desktop/project/node_modules/gulp-sass/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /Users/user/Desktop/project/node_modules/gulp-sass/node_modules/node-sass
Output:
Building: /usr/local/Cellar/node#16/16.13.0/libexec/node /Users/user/Desktop/project/node_modules/gulp-sass/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 [
gyp verb cli '/usr/local/Cellar/node#16/16.13.0/libexec/node',
gyp verb cli '/Users/user/Desktop/project/node_modules/gulp-sass/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 verb cli ]
gyp info using node-gyp#3.8.0
gyp info using node#16.13.0 | 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 "/usr/local/opt/python#3.9/bin/python3" in the PATH
gyp verb `which` succeeded /usr/local/opt/python#3.9/bin/python3 /usr/local/opt/python#3.9/bin/python3
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /usr/local/opt/python#3.9/bin/python3 -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:397:12)
gyp ERR! stack at ChildProcess.emit (node:events:390:28)
gyp ERR! stack at maybeClose (node:internal/child_process:1064:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
gyp ERR! System Darwin 21.1.0
gyp ERR! command "/usr/local/Cellar/node#16/16.13.0/libexec/node" "/Users/user/Desktop/project/node_modules/gulp-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /Users/user/Desktop/project/node_modules/gulp-sass/node_modules/node-sass
gyp ERR! node -v v16.13.0
Fixed!
I just had a problem with the version of Node on my laptop.

error ~node_modules/node-sass: Command failed Exit code: 1 Command: node scripts/build.js when running rails new application

Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: ~/workspace/testest/node_modules/node-sass
Output:
Building: ~/.nvm/versions/node/v15.4.0/bin/node ~/workspace/testest/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 `which` failed code: 'ENOENT'
gyp verb `which` failed }
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "python", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (~workspace/testest/node_modules/node-gyp/lib/configure.js:484:19)
gyp ERR! stack at PythonFinder.<anonymous> (~workspace/testest/node_modules/node-gyp/lib/configure.js:406:16)
gyp ERR! command "~.nvm/versions/node/v15.4.0/bin/node" "~workspace/testest/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd ~workspace/testest/node_modules/node-sass
gyp ERR! node -v v15.4.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
Really have no idea what actually happens. I don't know when this happened (I built a lot of rails apps for my study but had no problem before) but just recently noticed.
Make sure you have python installed on your machine.
On your terminal RUN which python
It should return your python location path that looks something like
/usr/local/bin/python
Then run
npm config set python </usr/local/bin/python>
OR
just RUN export PYTHON="$(which python3)"

npm install no longer works but did an hour ago

Can someone please help me understand what is going on here, this loaded fine an hour ago, but now it won't, I've removed the node modules and run npm cache clear --force, but still nothing. This is the error I'm getting. I'm certain it is something really really simple, I am completely new to javascript, so it's likely to be more obvious than you think.
Building: /usr/bin/node /home/rob/Development/vue-getting-started/03-data-and-events/begin/vue-heroes/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 [
gyp verb cli '/usr/bin/node',
gyp verb cli '/home/rob/Development/vue-getting-started/03-data-and-events/begin/vue-heroes/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 verb cli ]
gyp info using node-gyp#3.8.0
gyp info using node#14.15.5 | linux | 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 "/home/rob/anaconda3/bin/python3" in the PATH
gyp verb `which` succeeded /home/rob/anaconda3/bin/python3 /home/rob/anaconda3/bin/python3
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /home/rob/anaconda3/bin/python3 -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:308:12)
gyp ERR! stack at ChildProcess.emit (events.js:315:20)
gyp ERR! stack at maybeClose (internal/child_process.js:1048:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
gyp ERR! System Linux 5.4.0-65-generic
gyp ERR! command "/usr/bin/node" "/home/rob/Development/vue-getting-started/03-data-and-events/begin/vue-heroes/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/rob/Development/vue-getting-started/03-data-and-events/begin/vue-heroes/node_modules/node-sass
gyp ERR! node -v v14.15.5
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
Build failed with error code: 1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! node-sass#4.12.0 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.12.0 postinstall 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/rob/.npm/_logs/2021-02-15T22_46_40_202Z-debug.log
Is there anyone that is familiar with this please, people are suggesting that I install python2.7 and other libraries that are in the error message. I can't read javascript, I'm learning it, but I know this is neither an issue with python2.7 or "node-gyp" as neither of these were installed when I had node running fine. This really is a newbie issue, there must be a simple fix for this.

npm install faills with python module errors

I am trying to install and run a react project which I bought from the internet. wheever, I run npm install I get the following error
gyp verb `which` failed code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python /home/AzureUser/Python3/python
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /home/AzureUser/Python3/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:198:13)
gyp ERR! stack at maybeClose (internal/child_process.js:982:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
gyp ERR! System Linux 4.18.0-193.6.3.el8_2.x86_64
gyp ERR! command "/usr/bin/node" "/var/tmp/thermo-api/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /var/tmp/thermo-api/node_modules/node-sass
gyp ERR! node -v v10.21.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok
I am very new to node.js and I am not sure what is wrong?

NodeJS npm install throws error

I am new to NodeJS and I am trying to install node saas by sudo npm install -g --unsafe-perms node-sass
and I see this
/usr/local/bin/node-sass -> /usr/local/lib/node_modules/node-sass/bin/node-sass
> node-sass#4.7.2 install /usr/local/lib/node_modules/node-sass
> node scripts/install.js
Unable to save binary /usr/local/lib/node_modules/node-sass/vendor/linux-x64-59 : { Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/vendor'
at Object.fs.mkdirSync (fs.js:905:18)
at sync (/usr/local/lib/node_modules/node-sass/node_modules/mkdirp/index.js:71:13)
at Function.sync (/usr/local/lib/node_modules/node-sass/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/usr/local/lib/node_modules/node-sass/scripts/install.js:111:11)
at Object.<anonymous> (/usr/local/lib/node_modules/node-sass/scripts/install.js:154:1)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
errno: -13,
code: 'EACCES',
syscall: 'mkdir',
path: '/usr/local/lib/node_modules/node-sass/vendor' }
> node-sass#4.7.2 postinstall /usr/local/lib/node_modules/node-sass
> node scripts/build.js
Building: /usr/local/bin/node /usr/local/lib/node_modules/node-sass/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 [ '/usr/local/bin/node',
gyp verb cli '/usr/local/lib/node_modules/node-sass/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#9.4.0 | linux | 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` succeeded python2 /usr/bin/python2
gyp verb check python version `/usr/bin/python2 -c "import platform; print(platform.python_version());"` returned: "2.7.12\n"
gyp verb get node dir no --target version specified, falling back to host node version: 9.4.0
gyp verb command install [ '9.4.0' ]
gyp verb install input version string "9.4.0"
gyp verb install installing version: 9.4.0
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: 9.4.0
gyp verb build dir attempting to create "build" dir: /usr/local/lib/node_modules/node-sass/build
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/node-sass/build'
gyp ERR! System Linux 4.13.0-32-generic
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/node-sass/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /usr/local/lib/node_modules/node-sass
gyp ERR! node -v v9.4.0
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#4.7.2 postinstall: `node scripts/build.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the node-sass#4.7.2 postinstall 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/baig772/.npm/_logs/2018-02-14T18_01_56_774Z-debug.log
sudo chown -R $USER:admin /usr/local

Resources