javascriptreactjsruby-on-railsnpmpackage

Failed doing npm install showing error "Undefined variable standalone_static_library in binding.gyp" and node-sass chokidar error


I'm updating a 3 years ago ruby on rails and react project trying to npm install but im stuck here getting this error

$ npm install

gyp: Undefined variable standalone_static_library in binding.gyp while trying to load binding.gyp
gyp ERR! configure error 
gyp ERR! stack Error: `gyp` failed with exit code: 1

$ npm start

sh: node-sass-chokidar: command not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! frontend@0.1.0 build-css: `node-sass-chokidar src/styles -o src/styles`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the frontend@0.1.0 build-css script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

I tried removing node_modules, update node version and npm version.


Solution

  • For me this issue happened with NodeJS 19 (specifically 19.2.0) Run node --version to get your version (or you might see the output of that command in the gyp error logs, in my case later when I use NodeJS v20: npm ERR! gyp ERR! node -v v20.10.0)

    The issue is fixed when I reverted to NodeJS 18; aka NodeJS LTS (at the time I wrote this answer, 12/9/2022). I used nvm install 18 and nvm use 18 as described here here and here)

    NodeJS LTS = Long Term Support; "recommended for most users". At the time I wrote this answer (12/9/2022), Node Long Term Support (LTS) is NodeJS version 18.12.1

    It seems like this issue (Undefined variable standalone_static_library...) may have been introduced in NodeJS version 19 because:

    node 19.0.0 has been changed to make process.config read only #43627

    After reverting, it may still be mentioned as a warning, but not an error:

    npm ERR! (node:7120) [DEP0150] DeprecationWarning: Setting process.config is deprecated. In the future the property will be read-only.

    And while we're talking about versions, be careful about Python3 vs Python2!

    npm ERR! gyp verb which failed Error: not found: python2