Reputation: 2008
When doing yarn install
i get this error, but no issues one other projects, also used Brew to install node. Note sure what else should i try, any suggestions?
error */node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: */node_modules/node-sass
Output:
Building: /opt/homebrew/Cellar/node@14/14.18.1/bin/node */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@14/14.18.1/bin/node',
gyp verb cli '*/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 [email protected]
gyp info using [email protected] | 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 "/opt/homebrew/opt/[email protected]/bin/python3" in the PATH
gyp verb `which` succeeded /opt/homebrew/opt/[email protected]/bin/python3 /opt/homebrew/opt/[email protected]/bin/python3
gyp ERR! configure error
gyp ERR! stack Error: Command failed: /opt/homebrew/opt/[email protected]/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:383:12)
gyp ERR! stack at ChildProcess.emit (events.js:400:28)
gyp ERR! stack at maybeClose (internal/child_process.js:1058:16)
gyp ERR! stack at Socket.<anonymous> (internal/child_process.js:443:11)
gyp ERR! stack at Socket.emit (events.js:400:28)
gyp ERR! stack at Pipe.<anonymous> (net.js:686:12)
gyp ERR! System Darwin 21.1.0
gyp ERR! command "/opt/homebrew/Cellar/node@14/14.18.1/bin/node" "*/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd */node_modules/node-sass
gyp ERR! node -v v14.18.1
Upvotes: 36
Views: 54474
Reputation: 2008
Fixed by upping the node-sass version to the correct version based on my Node installation as documented here: https://npmjs.com/package/node-sass
Upvotes: 18
Reputation: 7561
In my mac, I had this problem and when I ran python2
command, I had this:
> python2
pyenv: python2: command not found
The `python2' command exists in these Python versions:
2.7.18
Note: See 'pyenv help global' for tips on allowing both
python2 and python3 to be found.
All I needed was pyenv global 2.7.18
to add python2 to the global.
Upvotes: 0
Reputation: 121
The reason for the error is executing a Python2 program with Python3. The syntax of print
is different between Python2 and Python3.
print 'some text' # python 2.x
print('some text') # python 3
That is to say, the node-gyp
package that node-sass
depends on is still written in Python2.
The solution is simple:
.npmrc
or .yarnrc
.Regarding the second point, take macOS as an example:
$ which python
/Users/frankie/.pyenv/shims/python
$ npm config set python /Users/frankie/.pyenv/shims/python
Upvotes: 10
Reputation: 106
For me the solution was to delete the file 'package-lock.json' and then run 'npm install'.
The answer "For me it was enough to remove yarn.lock and run yarn install again." from FedericoCapaldo pointed me to the right direction.
Upvotes: 1
Reputation: 2001
At the time of writing this answer, the current version of Node was 18 and the recommended version was 16. When trying to install a slightly older project, I was getting a request to install node-gyp
. The specified error has appeared. I followed bdn's suggestion and installed 14. Now, not only that it didn't require node-gyp
, it also installed smoothly.
nvm install 14
nvm exec 14 npm install
Upvotes: 3
Reputation: 41
gyp ERR! stack
import sys; print "%s.%s.%s" % sys.version_info[:3];
Invalid syntax
This error occur due to python3 is used for executing the python2-only command line. I have tried executing the command with python2 and it work fine.
So the solution is temporarily removing python3 and replace python3's path with python2's path in your windows Environment Variables. Then run the npm line again!
This work for me so I hope it help you guys too
Upvotes: 4
Reputation: 531
Just abandon node-sass
, because it deprecated. Instead I advise you to use sass
npm package.
Upvotes: 0
Reputation: 5962
I'm getting this error while building the Vue.js and adding the Buefy to it:
File "<string>", line 1
gyp ERR! stack import sys; print "%s.%s.%s" % sys.version_info[:3];
It seems that in my case the problem was that the version of node
was not compatible with the version of node-sass
in the package.json
.
So the solution is to find a node-sass
version compatible with the version of node installed on your machine.
Since I'm working on a fresh project to fix I could simply update my node
the the last version and then use the node-sass
compatible with it. Check this list to find out what's compatible
In my case this I did the following
1 | I updated the NODE to the last version (v16 in my case)
npm cache clean -f
npm install -g n
n stable
2 | I changed my node-sass
version to the one compatible with node v16 in the package.json which is "node-sass": "~6.0",
Now, if I run yarn install
it works like a charm
Upvotes: 6
Reputation: 19
There is a bug in print "%s.%s.%s" % sys.version_info[:3]; parentheses missed, it should be print("%s.%s.%s" % sys.version_info[:3]);
Upvotes: 1
Reputation: 1570
I've had the same problem on the same hardware. Node 17 installed via brew. I checked https://www.npmjs.com/package/node-sass and it says node 17 required node-sass 7.0+. I set node-sass to ^7.0.0 in my package.json which solved the problem for me.
Upvotes: 1
Reputation: 55
My node-sass
version in package.json
is 6.0.0 and my node version is 16.13.1. As the node-sass documentations, the node-sass 6.0+
requires Node16 but I still get stuck with the same problem when using the command npm install
or yarn
Then, I tried to downgrade to Node14, it worked correctly (??!!). I don't know why and can not find any solutions or explanations on google so far.
Upvotes: 1
Reputation: 31
I removed my brew setup :
brew remove yarn
brew remove node
brew remove node@14
Then reinstalled everything without brew, this link helped me a lot : https://www.jurnalanas.com/node-js-mac-m1/
Finally reinstalled yarn :
rm -rf ~/.yarn
curl -o- -L https://yarnpkg.com/install.sh | bash
Upvotes: 3
Reputation: 11
I resolved similar issue by changing node-sass version in package.json to "node-sass": "4.14.1".
My "node --version" = "v14.18.0" and "npm --version" = "6.14.15"
Upvotes: 1
Reputation: 91
After updating MacOS to Monterey, this problem appeared. Simply reinstall and relink node version, and everything fixed.
Changed version to node@14 and fixed it. What i've done:
brew install node@14
brew unlink node
brew link --overwrite node@14
Here is an article with commands I've used https://medium.com/@georgeenathomas/3-step-process-to-downgrade-node-version-using-homebrew-bc0b0a72ae27
Upvotes: 8