node-sass breaking on Ubuntu 20
See original GitHub issueDescription
I shifted my development from macOS to Ubuntu 20 which removes python2 from their system which makes sense since it’s discontinued. The gatsby-plugin-sass
rely on node-sass@4.14.1
which internally relies on node-gyp@3.8.0
. The screenshot below might help to clear the dependency.
I alias the python
command to python3
, now the issue is during yarn install
step node-gyp is building the project which runs a python2
command and due to which project is unable to build.
The issue will be fixed if we use node-sass@5.0.0
since it rely on node-gyp@7.1.0
which supports python3
.
Steps to reproduce
If you are on Ubuntu 20 run yarn install
on your gatsby project and you will get the error.
Expected result
I expect the node-sass build to be successful.
Actual result
error /home/aziz/Documents/github.com/iAziz786/iAziz786.com/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments:
Directory: /home/aziz/Documents/github.com/iAziz786/iAziz786.com/node_modules/node-sass
Output:
Building: /usr/bin/node /home/aziz/Documents/github.com/iAziz786/iAziz786.com/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/aziz/Documents/github.com/iAziz786/iAziz786.com/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@15.0.1 | 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 "/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:309:12)
gyp ERR! stack at ChildProcess.emit (node:events:327:20)
gyp ERR! stack at maybeClose (node:internal/child_process:1048:16)
gyp ERR! stack at Process.ChildProcess._handle.onexit (node:internal/child_process:288:5)
gyp ERR! System Linux 5.4.0-52-generic
gyp ERR! command "/usr/bin/node" "/home/aziz/Documents/github.com/iAziz786/iAziz786.com/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/aziz/Documents/github.com/iAziz786/iAziz786.com/node_modules/node-sass
gyp ERR! node -v v15.0.1
Environment
System:
OS: Linux 5.4 Ubuntu 20.04.1 LTS (Focal Fossa)
CPU: (4) x64 Intel(R) Core(TM) i3-2120 CPU @ 3.30GHz
Shell: 5.8 - /usr/bin/zsh
Binaries:
Node: 15.0.1 - /usr/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 7.0.3 - /usr/bin/npm
Languages:
Python: 3.8.5 - /usr/bin/python
Browsers:
Chrome: 86.0.4240.111
Firefox: 82.0
npmPackages:
gatsby: ^2.24.23 => 2.24.23
gatsby-image: ^2.4.14 => 2.4.14
gatsby-plugin-google-analytics: ^2.3.13 => 2.3.13
gatsby-plugin-manifest: ^2.4.21 => 2.4.21
gatsby-plugin-mdx: ^1.2.30 => 1.2.30
gatsby-plugin-offline: ^3.2.21 => 3.2.21
gatsby-plugin-postcss: ^2.3.11 => 2.3.11
gatsby-plugin-react-helmet: ^3.3.10 => 3.3.10
gatsby-plugin-robots-txt: ^1.5.1 => 1.5.1
gatsby-plugin-sass: ^2.3.12 => 2.3.12
gatsby-plugin-sharp: ^2.6.24 => 2.6.24
gatsby-plugin-sitemap: ^2.4.11 => 2.4.11
gatsby-plugin-typography: ^2.5.10 => 2.5.10
gatsby-remark-copy-linked-files: ^2.3.12 => 2.3.12
gatsby-remark-images: ^3.3.23 => 3.3.23
gatsby-remark-prismjs: ^3.5.10 => 3.5.10
gatsby-remark-reading-time: ^1.1.0 => 1.1.0
gatsby-remark-responsive-iframe: ^2.4.12 => 2.4.12
gatsby-remark-smartypants: ^2.3.10 => 2.3.10
gatsby-source-filesystem: ^2.3.23 => 2.3.23
gatsby-transformer-remark: ^2.8.27 => 2.8.27
gatsby-transformer-sharp: ^2.5.12 => 2.5.12
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:6 (6 by maintainers)
Top Results From Across the Web
Can't install 'node-sass' on Ubuntu 20 - Stack Overflow
Run this commands: rm -rf ./node_modules ./package-lock.json , then npm cache verify . PS: I recommend to install nvm
Read more >Ubuntu Manpage: node-sass - Node.js bindings to libsass
npm install node-sass Some users have reported issues installing on Ubuntu due to node being registered to another package. Follow the official NodeJS...
Read more >node-sass - npm
Start using node-sass in your project by running `npm i node-sass`. There are 12485 other projects in the npm registry using node-sass.
Read more >Node/npm start on Ubuntu 18.04 build error with node-sass
I'm running an AWS Ubuntu 18.04 LTS. I use NVM for managing node versions. I'm having issues with node-sass and npm. The build...
Read more >node sass does not yet support your current environment ...
install the compatible node-sass version via npm install node-sass@4.14.0 ; you can find the list here, or even install gulp-sass with npm i...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Okay, to check whether it works out of the box or not I removed the alias I created for the
python
command topython3
. Since by default, it won’t be there on Ubuntu 20 and…It worked! 🎉
Looks like the version 5 of
node-sass
can handle the absence ofpython
command.@kalwalt In my case upgrading to
node-sass@5.0.0
has fixed the issue.I’m not sure whether the
peerDependencies
ofgatsby-plugin-sass
should be upgraded tonode-sass@5.0.0
or not. I’ll ask on the discord for the answer.