Build problem with node version

Hi,
I forked a GitHub repo and tried to deploy it on Netlify, but I am getting an error when deploying the code via the Netlify website.

The error is in the build stage and with the node version I think.
Even though I set the Node version to 18.x in the site configuration, I see in the logs that the Node version is v14.

I want to know why the Node version does not apply to the project.

12:00:56 PM: Netlify Build                                                 
12:00:56 PM: ────────────────────────────────────────────────────────────────
12:00:56 PM: ​
12:00:56 PM: ❯ Version
12:00:56 PM:   @netlify/build 29.58.9
12:00:56 PM: ​
12:00:56 PM: ❯ Flags
12:00:56 PM:   accountId: 67b2d13ab7f3d3bab81cfb32
12:00:56 PM:   baseRelDir: true
12:00:56 PM:   buildId: 67b44503af70683210bd4571
12:00:56 PM:   deployId: 67b44503af70683210bd4573
12:00:56 PM: ​
12:00:56 PM: ❯ Current directory
12:00:56 PM:   /opt/build/repo
12:00:56 PM: ​
12:00:56 PM: ❯ Config file
12:00:56 PM:   No config file was defined: using default values.
12:00:56 PM: ​
12:00:56 PM: ❯ Context
12:00:56 PM:   production
12:00:56 PM: ​
12:00:56 PM: ❯ Installing plugins
12:00:56 PM:    - @netlify/plugin-gatsby@3.8.2
12:01:06 PM: ​
12:01:06 PM: Dependencies installation error                               
12:01:06 PM: ────────────────────────────────────────────────────────────────
12:01:06 PM: ​
12:01:06 PM:   Error message
12:01:06 PM:   Error while installing dependencies in /opt/build/repo/.netlify/plugins/
12:01:06 PM: ​
12:01:06 PM:   > @parcel/watcher@2.5.1 install /opt/build/repo/.netlify/plugins/node_modules/@parcel/watcher
12:01:06 PM:   > node scripts/build-from-source.js
12:01:06 PM: ​​
12:01:06 PM:   > sharp@0.32.6 install /opt/build/repo/.netlify/plugins/node_modules/sharp
12:01:06 PM:   > (node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)
12:01:06 PM: ​
12:01:06 PM:   sharp: Detected globally-installed libvips v8.15.1
12:01:06 PM:   sharp: Building from source via node-gyp
12:01:06 PM:   Traceback (most recent call last):
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/gyp_main.py", line 50, in <module>
12:01:06 PM:       sys.exit(gyp.script_main())
12:01:06 PM:                ~~~~~~~~~~~~~~~^^
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 554, in script_main
12:01:06 PM:       return main(sys.argv[1:])
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 547, in main
12:01:06 PM:       return gyp_main(args)
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 520, in gyp_main
12:01:06 PM:       [generator, flat_list, targets, data] = Load(
12:01:06 PM:                                               ~~~~^
12:01:06 PM:           build_files, format, cmdline_default_variables, includes, options.depth,
12:01:06 PM:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:01:06 PM:           params, options.check, options.circular_check,
12:01:06 PM:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:01:06 PM:           options.duplicate_basename_check)
12:01:06 PM:           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/__init__.py", line 136, in Load
12:01:06 PM:       result = gyp.input.Load(build_files, default_variables, includes[:],
12:01:06 PM:                               depth, generator_input_info, check, circular_check,
12:01:06 PM:                               duplicate_basename_check,
12:01:06 PM:                               params['parallel'], params['root_targets'])
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 2782, in Load
12:01:06 PM:       LoadTargetBuildFile(build_file, data, aux_data,
12:01:06 PM:       ~~~~~~~~~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:01:06 PM:                           variables, includes, depth, check, True)
12:01:06 PM:                           ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 391, in LoadTargetBuildFile
12:01:06 PM:       build_file_data = LoadOneBuildFile(build_file_path, data, aux_data,
12:01:06 PM:                                          includes, True, check)
12:01:06 PM:     File "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/gyp/pylib/gyp/input.py", line 234, in LoadOneBuildFile
12:01:06 PM:       build_file_contents = open(build_file_path, 'rU').read()
12:01:06 PM:                             ~~~~^^^^^^^^^^^^^^^^^^^^^^^
12:01:06 PM:   ValueError: invalid mode: 'rU' while trying to load binding.gyp
12:01:06 PM:   gyp ERR! configure error
12:01:06 PM:   gyp ERR! stack Error: `gyp` failed with exit code: 1
12:01:06 PM:   gyp ERR! stack     at ChildProcess.onCpExit (/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/lib/configure.js:351:16)
12:01:06 PM:   gyp ERR! stack     at ChildProcess.emit (events.js:315:20)
12:01:06 PM:   gyp ERR! stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
12:01:06 PM:   gyp ERR! System Linux 5.10.228-219.884.amzn2.x86_64
12:01:06 PM:   gyp ERR! command "/opt/buildhome/.nvm/versions/node/v14.16.0/bin/node" "/opt/buildhome/.nvm/versions/node/v14.16.0/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
12:01:06 PM:   gyp ERR! cwd /opt/build/repo/.netlify/plugins/node_modules/sharp
12:01:06 PM:   gyp ERR! node -v v14.16.0
12:01:06 PM:   gyp ERR! node-gyp -v v5.1.0
12:01:06 PM:   gyp ERR! not ok
12:01:06 PM:   npm WARN notsup Unsupported engine for @netlify/plugin-gatsby@3.8.2: wanted: {"node":">=14.17.0"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: @netlify/plugin-gatsby@3.8.2
12:01:06 PM:   npm WARN notsup Unsupported engine for @netlify/serverless-functions-api@1.26.1: wanted: {"node":">=18.0.0"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: @netlify/serverless-functions-api@1.26.1
12:01:06 PM:   npm WARN notsup Unsupported engine for consola@3.4.0: wanted: {"node":"^14.18.0 || >=16.10.0"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: consola@3.4.0
12:01:06 PM:   npm WARN notsup Unsupported engine for clipboardy@4.0.0: wanted: {"node":">=18"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: clipboardy@4.0.0
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-win32-x64@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-win32-x64):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-win32-x64@2.5.1: wanted {"os":"win32","arch":"x64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-linux-arm64-glibc@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-linux-arm64-glibc):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-linux-arm64-glibc@2.5.1: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-darwin-arm64@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-darwin-arm64):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-darwin-arm64@2.5.1: wanted {"os":"darwin","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-linux-arm64-musl@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-linux-arm64-musl):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-linux-arm64-musl@2.5.1: wanted {"os":"linux","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-linux-arm-glibc@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-linux-arm-glibc):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-linux-arm-glibc@2.5.1: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-android-arm64@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-android-arm64):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-android-arm64@2.5.1: wanted {"os":"android","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-win32-ia32@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-win32-ia32):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-win32-ia32@2.5.1: wanted {"os":"win32","arch":"ia32"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-linux-arm-musl@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-linux-arm-musl):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-linux-arm-musl@2.5.1: wanted {"os":"linux","arch":"arm"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-win32-arm64@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-win32-arm64):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-win32-arm64@2.5.1: wanted {"os":"win32","arch":"arm64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-freebsd-x64@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-freebsd-x64):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-freebsd-x64@2.5.1: wanted {"os":"freebsd","arch":"x64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: @parcel/watcher-darwin-x64@2.5.1 (node_modules/@parcel/watcher/node_modules/@parcel/watcher-darwin-x64):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for @parcel/watcher-darwin-x64@2.5.1: wanted {"os":"darwin","arch":"x64"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN notsup Unsupported engine for is-wsl@3.1.0: wanted: {"node":">=16"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: is-wsl@3.1.0
12:01:06 PM:   npm WARN notsup Unsupported engine for execa@8.0.1: wanted: {"node":">=16.17"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: execa@8.0.1
12:01:06 PM:   npm WARN notsup Unsupported engine for is64bit@2.0.0: wanted: {"node":">=18"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: is64bit@2.0.0
12:01:06 PM:   npm WARN notsup Unsupported engine for human-signals@5.0.0: wanted: {"node":">=16.17.0"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: human-signals@5.0.0
12:01:06 PM:   npm WARN notsup Unsupported engine for get-stream@8.0.1: wanted: {"node":">=16"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: get-stream@8.0.1
12:01:06 PM:   npm WARN notsup Unsupported engine for system-architecture@0.1.0: wanted: {"node":">=18"} (current: {"node":"14.16.0","npm":"6.14.11"})
12:01:06 PM:   npm WARN notsup Not compatible with your version of node/npm: system-architecture@0.1.0
12:01:06 PM:   npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.3.2 (node_modules/chokidar/node_modules/fsevents):
12:01:06 PM:   npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.3.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
12:01:06 PM:   npm WARN @netlify/plugin-gatsby@3.8.2 requires a peer of @gatsbyjs/reach-router@* but none is installed. You must install peer dependencies yourself.
12:01:06 PM:   npm WARN @netlify/plugin-gatsby@3.8.2 requires a peer of common-tags@^1.8.2 but none is installed. You must install peer dependencies yourself.
12:01:06 PM: ​
12:01:06 PM:   npm ERR! code ELIFECYCLE
12:01:06 PM:   npm ERR! errno 1
12:01:06 PM:   npm ERR! sharp@0.32.6 install: `(node install/libvips && node install/dll-copy && prebuild-install) || (node install/can-compile && node-gyp rebuild && node install/dll-copy)`
12:01:06 PM:   npm ERR! Exit status 1
12:01:06 PM:   npm ERR!
12:01:06 PM:   npm ERR! Failed at the sharp@0.32.6 install script.
12:01:06 PM:   npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
12:01:06 PM: ​​
12:01:06 PM:   Resolved config
12:01:06 PM:   build:
12:01:06 PM:     command: yarn run build
12:01:06 PM:     commandOrigin: ui
12:01:06 PM:     environment:
12:01:06 PM:       - NPM_FLAGS
12:01:06 PM:     publish: /opt/build/repo/public
12:01:06 PM:     publishOrigin: ui
12:01:06 PM:   plugins:
12:01:06 PM:     - inputs: {}
12:01:06 PM:       origin: ui
12:01:06 PM:       package: '@netlify/plugin-gatsby'
12:01:06 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:01:06 PM: Failing build: Failed to build site
12:01:07 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
12:01:07 PM: Finished processing build request in 1m2.469s

@jalilimmd This is to be expected due to your .nvmrc file:

The fact it takes precedence is mentioned in the documentation here:
https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript

Note that a NODE_VERSION environment variable, .node-version file, or .nvmrc file will override this UI setting.

2 Likes

Thanks for the quick help @nathanmartin

1 Like