2

Trying to get a project built on Ruby to run locally but I'm running into an issue (or a few) node-sass: command failed when running yarn install. After that it goes downhill. I have installed Node, Ruby, Rails, etc but I can't find a solution for that. I've tried to install node-sass via npm then running yarn install once again to install the other dependencies, but I got the same result...

I got this error below:

error /home/fernie/theodinproject/node_modules/node-sass: Command failed.
Exit code: 1
Command: node scripts/build.js
Arguments: 
Directory: /home/fernie/theodinproject/node_modules/node-sass
Output:
Building: /home/fernie/.nvm/versions/node/v15.14.0/bin/node /home/fernie/theodinproject/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   '/home/fernie/.nvm/versions/node/v15.14.0/bin/node',
gyp verb cli   '/home/fernie/theodinproject/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.14.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` failed Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/fernie/theodinproject/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/fernie/theodinproject/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/fernie/theodinproject/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/fernie/theodinproject/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/fernie/theodinproject/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/fernie/theodinproject/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:193:21)
gyp verb `which` failed  python2 Error: not found: python2
gyp verb `which` failed     at getNotFoundError (/home/fernie/theodinproject/node_modules/which/which.js:13:12)
gyp verb `which` failed     at F (/home/fernie/theodinproject/node_modules/which/which.js:68:19)
gyp verb `which` failed     at E (/home/fernie/theodinproject/node_modules/which/which.js:80:29)
gyp verb `which` failed     at /home/fernie/theodinproject/node_modules/which/which.js:89:16
gyp verb `which` failed     at /home/fernie/theodinproject/node_modules/isexe/index.js:42:5
gyp verb `which` failed     at /home/fernie/theodinproject/node_modules/isexe/mode.js:8:5
gyp verb `which` failed     at FSReqCallback.oncomplete (node:fs:193: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 /usr/bin/python
gyp ERR! configure error 
gyp ERR! stack Error: Command failed: /usr/bin/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 (node:child_process:326:12)
gyp ERR! stack     at ChildProcess.emit (node:events:369:20)
gyp ERR! stack     at maybeClose (node:internal/child_process:1067:16)
gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
gyp ERR! System Linux 5.8.0-50-generic
gyp ERR! command "/home/fernie/.nvm/versions/node/v15.14.0/bin/node" "/home/fernie/theodinproject/node_modules/node-gyp/bin/node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd /home/fernie/theodinproject/node_modules/node-sass
gyp ERR! node -v v15.14.0
gyp ERR! node-gyp -v v3.8.0
gyp ERR! not ok 

package.json

{
  "license": "MIT",
  "scripts": {
    "test": "jest --coverage",
    "eslint": "eslint --max-warnings 0 './app/javascript/**/*'"
  },
  "dependencies": {
    "@babel/preset-react": "^7.13.13",
    "@hookform/resolvers": "^0.1.1",
    "@rails/ujs": "^6.1.3",
    "@rails/webpacker": "5.2.1",
    "@sentry/browser": "^6.2.5",
    "axios": "^0.21.1",
    "babel-plugin-prismjs": "^2.0.1",
    "babel-plugin-transform-react-remove-prop-types": "^0.4.24",
    "bootstrap": "^4.5.3",
    "core-js": "^3.10.1",
    "hint.css": "^2.6.0",
    "jquery": "^3.6.0",
    "js-base64": "^3.6.0",
    "node-sass": "^4.14.1",
    "popper.js": "^1.16.1",
    "prismjs": "^1.23.0",
    "prop-types": "^15.7.2",
    "react": "^16.14.0",
    "react_ujs": "^2.6.1",
    "react-dom": "^16.14.0",
    "react-flip-move": "^3.0.4",
    "react-hook-form": "^6.15.1",
    "react-scrolllock": "^5.0.1",
    "react-tabs": "^3.2.2",
    "regenerator-runtime": "^0.13.7",
    "stickyfilljs": "^2.1.0",
    "toaster": "^0.1.2",
    "turbolinks": "^5.2.0",
    "validate.js": "^0.13.1",
    "yup": "^0.32.9"
  },
  "devDependencies": {
    "@testing-library/jest-dom": "^5.11.10",
    "@testing-library/react": "^11.2.6",
    "eslint": "^7.24.0",
    "eslint-config-airbnb": "^18.2.1",
    "eslint-plugin-import": "^2.22.1",
    "eslint-plugin-jsx-a11y": "^6.4.1",
    "eslint-plugin-react": "^7.23.2",
    "eslint-plugin-react-hooks": "^4.2.0",
    "jest": "^26.6.3",
    "webpack-dev-server": "^3.11.2"
  },
  "jest": {
    "clearMocks": true,
    "testPathIgnorePatterns": [
      "<rootDir>/config/",
      "/node_modules/",
      "/vendor/"
    ],
    "setupFilesAfterEnv": [
      "<rootDir>/setupTests.js"
    ]
  }
}

It seems that node-sass is a webpacker dependency, right? Because this happens after yarn runs @rails/webpacker.

Everything is up-to-date I think

$ node -v
v15.14.0
$ node-sass -v
node-sass    5.0.0    (Wrapper)    [JavaScript]
libsass      3.5.5    (Sass Compiler)    [C/C++]
$ yarn -v
1.22.10
$ ruby -v
ruby 2.6.6p146 (2020-03-31 revision 67876) [x86_64-linux]
$ rails -v
Rails 6.1.3.1
$ node-gyp -v
v8.0.0

Does anyone have any idea what could be causing this?

It's my first time contributing to a Ruby project and I don't wanna mess up. I appreciate any help

fernie
  • 57
  • 7
  • How does package.json look like? – razvans Apr 20 '21 at 07:31
  • Does this help https://stackoverflow.com/questions/45801457/node-js-python-not-found-exception-due-to-node-sass-and-node-gyp? – razvans Apr 20 '21 at 07:37
  • @razvans Thanks for your comment. I added the package.json to my question. I wonder if trying to install each dependency separately would work. But I don't think it's diferrent of running yarn install since when trying to run `rails webpacker:install` it throws the same error – fernie Apr 20 '21 at 07:50
  • Try a fresh install. Remove node modules, remove node-sass from package.json then `yarn install`. Not sure if globally installed node-sass matters, but probably it's work removing that too. Node 15 requires node-sass 5 and webpacker should install it. If not, try adding node-sass v5 in package.json. See here https://www.npmjs.com/package/node-sass – razvans Apr 20 '21 at 08:36
  • Tried that, no lucky. Also, there's node-gyp... If you notice it's outputting `v3.8.0`. but if I run `node-gyp -v` version `8.0.0` it's installed. I took a lock at the `yarn.lock` file and it seems that it expects that version of node-gyp, I'm guessing. I'll contact the people responsible for this project tho.I appreciate the help :) – fernie Apr 20 '21 at 09:06
  • 1
    @razvans Yep, it was node-gyp. I removed it and python3,and install `node-gyp@3.8.0` and python2. Then `yarn install` and it worked. lol – fernie Apr 20 '21 at 09:39
  • Does this answer your question? [\*\*node-sass: Command failed\*\* when rails new APP\_PATH](https://stackoverflow.com/questions/66143548/node-sass-command-failed-when-rails-new-app-path) – Stack Overflown May 23 '21 at 19:27
  • 1
    In package.json, I removed `node-sass` and changed the webpacker version to `"@rails/webpacker": "5.4.3"`. Then removed `node-modules` and did `yarn install` and it was working. – DariusP Jun 08 '22 at 20:42

0 Answers0