Roots Discourse

Unable to Build Sage with Node 12.15.0 / Mac OSX 64 Bit

Hi,

As of March 12th, 2020, I am unable to build sage using Yarn. I believe it’s dude to running Node 12.15.0. Is anyone else having this issue?

Here’s the error I get when I run Yarn.

gyp ERR! build error
gyp ERR! stack Error: make failed with exit code: 2
gyp ERR! stack at ChildProcess.onExit (/Users/myusername/Downloads/Sites/sage-test/wp-content/themes/sage-test/node_modules/node-gyp/lib/build.js:262:23)
gyp ERR! stack at ChildProcess.emit (events.js:223:5)
gyp ERR! stack at Process.ChildProcess._handle.onexit (internal/child_process.js:272:12)
gyp ERR! System Darwin 19.3.0
gyp ERR! command “/usr/local/bin/node” “/Users/myusername/Downloads/Sites/sage-test/wp-content/themes/sage-test/node_modules/node-gyp/bin/node-gyp.js” “rebuild” “–verbose” “–libsass_ext=” “–libsass_cflags=” “–libsass_ldflags=” “–libsass_library=”
gyp ERR! cwd /Users/myusername/Downloads/Sites/sage-test/wp-content/themes/sage-test/node_modules/node-sass
gyp ERR! node -v v12.15.0

Any help would be appreciated.

Hey, not sure what the maximum version is currently. But here is an old post of mine regarding node version at the time.

Hi Jordan,

I installed NVM and am running your exact version of Node and am getting this error when I run
‘npm run build’

npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! sage@9.0.0-beta.4 build: webpack --progress --config assets/build/webpack.config.js
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the sage@9.0.0-beta.4 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/jessebrede/.npm/_logs/2020-03-12T20_03_14_760Z-debug.log

From the error log:
0 info it worked if it ends with ok
1 verbose cli [ ‘/Users/jessebrede/.nvm/versions/node/v8.11.4/bin/node’,
1 verbose cli ‘/Users/jessebrede/.nvm/versions/node/v8.11.4/bin/npm’,
1 verbose cli ‘run’,
1 verbose cli ‘build’ ]
2 info using npm@5.6.0
3 info using node@v8.11.4
4 verbose run-script [ ‘prebuild’, ‘build’, ‘postbuild’ ]
5 info lifecycle sage@9.0.0-beta.4~prebuild: sage@9.0.0-beta.4
6 info lifecycle sage@9.0.0-beta.4~build: sage@9.0.0-beta.4
7 verbose lifecycle sage@9.0.0-beta.4~build: unsafe-perm in lifecycle true
8 verbose lifecycle sage@9.0.0-beta.4~build: PATH: /Users/jessebrede/.nvm/versions/node/v8.11.4/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/jessebrede/Downloads/Sites/allclearstage/wp-content/themes/allclear/node_modules/.bin:/Users/jessebrede/.nvm/versions/node/v8.11.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
9 verbose lifecycle sage@9.0.0-beta.4~build: CWD: /Users/jessebrede/Downloads/Sites/allclearstage/wp-content/themes/allclear
10 silly lifecycle sage@9.0.0-beta.4~build: Args: [ ‘-c’,
10 silly lifecycle ‘webpack --progress --config assets/build/webpack.config.js’ ]
11 silly lifecycle sage@9.0.0-beta.4~build: Returned: code: 2 signal: null
12 info lifecycle sage@9.0.0-beta.4~build: Failed to exec build script
13 verbose stack Error: sage@9.0.0-beta.4 build: webpack --progress --config assets/build/webpack.config.js
13 verbose stack Exit status 2
13 verbose stack at EventEmitter. (/Users/jessebrede/.nvm/versions/node/v8.11.4/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:285:16)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at EventEmitter.emit (events.js:214:7)
13 verbose stack at ChildProcess. (/Users/jessebrede/.nvm/versions/node/v8.11.4/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack at emitTwo (events.js:126:13)
13 verbose stack at ChildProcess.emit (events.js:214:7)
13 verbose stack at maybeClose (internal/child_process.js:925:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
14 verbose pkgid sage@9.0.0-beta.4
15 verbose cwd /Users/jessebrede/Downloads/Sites/allclearstage/wp-content/themes/allclear/assets
16 verbose Darwin 19.3.0
17 verbose argv “/Users/jessebrede/.nvm/versions/node/v8.11.4/bin/node” “/Users/jessebrede/.nvm/versions/node/v8.11.4/bin/npm” “run” “build”
18 verbose node v8.11.4
19 verbose npm v5.6.0
20 error code ELIFECYCLE
21 error errno 2
22 error sage@9.0.0-beta.4 build: webpack --progress --config assets/build/webpack.config.js
22 error Exit status 2
23 error Failed at the sage@9.0.0-beta.4 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 2, true ]
~

I don’t know about your second error, but I’ve had a lot of luck switching to sass (the official Dart implementation) from node-sass. The API is basically the same, so the switch is more or less drop-in, and it solved a lot of problems I had with node-sass. The npm page has instructions for switching to sass from node-sass: https://www.npmjs.com/package/sass

When you change your version of node you’ll also have to clear any downloaded node modules which you grabbed with the previous version of node. Node modules are stored in node_modules, so you could do:

nvm install 8 && nvm use 8
rm -rf node_modules/
yarn && yarn build

If you’re new to NVM it’s wise noting that when you close your terminal NVM could default to a newer version of node. So you may need to do nvm use 8 on each new terminal you spawn

Thank you. That worked.

For anyone having this issue. Install NVM and then run

nvm install 8 && nvm use 8

rm -rf node_modules/

yarn && yarn build