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.
NodeJS | Supported node-sass version | Node Module |
---|---|---|
Node 20 | 9.0+ | 115 |
Node 19 | 8.0+ | 111 |
Node 18 | 8.0+ | 108 |
Node 17 | 7.0+, <8.0 | 102 |
Node 16 | 6.0+ | 93 |
Node 15 | 5.0+, <7.0 | 88 |
Node 14 | 4.14+, <9.0 | 83 |
Node 13 | 4.13+, <5.0 | 79 |
Node 12 | 4.12+, <8.0 | 72 |
Node 11 | 4.10+, <5.0 | 67 |
Node 10 | 4.9+, <6.0 | 64 |
Node 8 | 4.5.3+, <5.0 | 57 |
Node <8 | <5.0 | <57 |
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 🎉