Skip to content

/node_modules/node-sass: Command failed.

Published: at 02:12 AM (1 min read)

Recently, while upgrading Node.js from version 14.17.3 to 20.9.0, I encountered a bunch of errors after running `yarn install`.

File \"/Users/camel/.node-gyp/18.18.2/include/node/common.gypi\", line 1
    e_data_file_flag%': 1
                        ^
SyntaxError: EOL while scanning string literal
gyp ERR! configure error
gyp ERR! stack Error: `gyp` failed with exit code: 1
gyp ERR! stack     at ChildProcess.onCpExit (/Users/camel/node_modules/node-gyp/lib/configure.js:345:16)
gyp ERR! stack     at ChildProcess.emit (node:events:517:28)
gyp ERR! stack     at ChildProcess._handle.onexit (node:internal/child_process:292:12)
gyp ERR! System Darwin 23.0.0

After some research, I found out that [node-sass](https://www.npmjs.com/package/node-sass) has compatibility issues with different versions of nodejs.

NodeJSSupported node-sass versionNode Module
Node 209.0+115
Node 198.0+111
Node 188.0+108
Node 177.0+, <8.0102
Node 166.0+93
Node 155.0+, <7.088
Node 144.14+, <9.083
Node 134.13+, <5.079
Node 124.12+, <8.072
Node 114.10+, <5.067
Node 104.9+, <6.064
Node 84.5.3+, <5.057
Node <8<5.0<57

https://www.npmjs.com/package/node-sass

Therefore, before upgrading, it is recommended to install the expected version of nodejs first, and then reinstall [node-sass](https://www.npmjs.com/package/node-sass).

yarn add node-sass

You can then proceed with yarn install successfully 🎉

Reference: