gatsbyjs / gatsby

The best React-based framework with performance, scalability and security built in.
https://www.gatsbyjs.com
MIT License
55.23k stars 10.32k forks source link

Node.js v18 support #35576

Closed paulober closed 2 years ago

paulober commented 2 years ago

Preliminary Checks

Description

When trying to run gatsby with Node.js 18 which is now current and will later this year transform into a new LTS release it get following error...

Is looks for me like the problem is "lmdb" dependency but from lmdb-js issue the author states from 2.3.5 it has support for nodejs 18.

Reproduction Link

ttps://github.com/gatsbyjs/gatsby-starter-default

Steps to Reproduce

Run gatsby develop with nodejs 18.

Expected Result

That gatsby develop works like with nodejs 16.

Actual Result

N:\WebDev\my-project\node_modules.pnpm\node-gyp-build@4.4.0\node_modules\node-gyp-build\index.js:60 throw new Error('No native build was found for ' + target + '\n loaded from: ' + dir + '\n') ^

Error: No native build was found for platform=win32 arch=x64 runtime=node abi=108 uv=1 libc=glibc node=18.0.0 loaded from: N:\WebDev\my-project\node_modules.pnpm\lmdb@2.2.6\node_modules\lmdb

at Function.load.path (N:\WebDev\my-project\node_modules\.pnpm\node-gyp-build@4.4.0\node_modules\node-gyp-build\index.js:60:9)
at load (N:\WebDev\my-project\node_modules\.pnpm\node-gyp-build@4.4.0\node_modules\node-gyp-build\index.js:22:30)
at Object.<anonymous> (N:\WebDev\my-project\node_modules\.pnpm\lmdb@2.2.6\node_modules\lmdb\node-index.js:17:45)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (N:\WebDev\my-project\node_modules\.pnpm\gatsby@4.13.1_xfl6eekid2lnnujkhjry6bwvou\node_modules\gatsby\src\utils\cache-lmdb.ts:1:1)

Environment

System:
    OS: Windows 10 10.0.22000
    CPU: (16) x64 AMD Ryzen 7 5800X 8-Core Processor             
  Binaries:
    Node: 18.1.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.18 - ~\AppData\Roaming\npm\yarn.CMD
    npm: 8.8.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.10.4
  Browsers:
    Edge: Spartan (44.22000.120.0), Chromium (101.0.1210.32)

Config Flags

No response

LekoArts commented 2 years ago

Hi @paulober 👋

Can you please try out gatsby@next (e.g. with npm install gatsby@next) as it contains an updated lmdb version. Thanks!

piducancore commented 2 years ago

Thank you both so much, I was scared af. I'm using gatsby@next with node v18.1.0 and it's working.

paulober commented 2 years ago

@LekoArts Still a problem when trying to install this package:

PS N:\testenv\test> npm install gatsby@next npm WARN ERESOLVE overriding peer dependency npm WARN While resolving: test@1.0.0 npm WARN Found: react@18.1.0 npm WARN node_modules/react npm WARN peer react@"^18.1.0" from react-dom@18.1.0 npm WARN node_modules/react-dom npm WARN react-dom@"^17.0.1" from the root project npm WARN 1 more (gatsby) npm WARN 2 more (the root project, gatsby) npm WARN npm WARN Could not resolve dependency: npm WARN peer react@"^18.1.0" from react-dom@18.1.0 npm WARN node_modules/react-dom npm WARN react-dom@"^17.0.1" from the root project npm WARN 1 more (gatsby) npm WARN deprecated async-cache@1.1.0: No longer maintained. Use [lru-cache](http://npm.im/lru-cache) version 7.6 or higher, and provide an asynchronousfetchMethodoption. npm WARN deprecated source-map-url@0.4.1: See https://github.com/lydell/source-map-url#deprecated npm WARN deprecated urix@0.1.0: Please see https://github.com/lydell/urix#deprecated npm WARN deprecated source-map-resolve@0.5.3: See https://github.com/lydell/source-map-resolve#deprecated npm WARN deprecated chokidar@2.1.8: Chokidar 2 does not receive security updates since 2019. Upgrade to chokidar 3 with 15x fewer dependencies npm WARN deprecated resolve-url@0.2.1: https://github.com/lydell/resolve-url#deprecated npm WARN deprecated querystring@0.2.0: The querystring API is considered Legacy. new code should use the URLSearchParams API instead. npm WARN deprecated babel-eslint@10.1.0: babel-eslint is now @babel/eslint-parser. This package will no longer receive updates. npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated uuid@3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details. npm WARN deprecated subscriptions-transport-ws@0.9.19: Thesubscriptions-transport-wspackage is no longer maintained. We recommend you usegraphql-wsinstead. For help migrating Apollo software tographql-ws, see https://www.apollographql.com/docs/apollo-server/data/subscriptions/#switching-from-subscriptions-transport-ws For general help usinggraphql-ws, see https://github.com/enisdenjo/graphql-ws/blob/master/README.md npm WARN cleanup Failed to remove some directories [ npm WARN cleanup [ npm WARN cleanup 'N:\\testenv\\test\\node_modules\\lmdb', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'N:\testenv\test\node_modules\lmdb'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'N:\\testenv\\test\\node_modules\\lmdb' npm WARN cleanup } npm WARN cleanup ], npm WARN cleanup [ npm WARN cleanup 'N:\\testenv\\test\\node_modules\\lmdb', npm WARN cleanup [Error: EBUSY: resource busy or locked, rmdir 'N:\testenv\test\node_modules\lmdb'] { npm WARN cleanup errno: -4082, npm WARN cleanup code: 'EBUSY', npm WARN cleanup syscall: 'rmdir', npm WARN cleanup path: 'N:\\testenv\\test\\node_modules\\lmdb' npm WARN cleanup } npm WARN cleanup ] npm WARN cleanup ] npm ERR! code 1 npm ERR! path N:\testenv\test\node_modules\gatsby\node_modules\gatsby\node_modules\lmdb npm ERR! command failed npm ERR! command C:\Windows\system32\cmd.exe /d /s /c node-gyp-build npm ERR! Die Projekte in dieser Projektmappe werden nacheinander erstellt. Um eine parallele Erstellung zu erm�glichen, m�ssen Sie den Schalter "-m" hinzuf�gen. npm ERR! lmdb-js.cpp npm ERR! C:\Users\user\AppData\Local\node-gyp\Cache\18.1.0\include\node\v8-initialization.h(14,10): fatal error C1083: Datei (Include) kann nicht ge�ffnet werden: "v8-platform.h": No such file or directory [N:\testenv\test\node_modules\gatsby\node_modules\gatsby\node_modules\lmdb\build\lmdb.vcxproj] npm ERR! gyp info it worked if it ends with ok npm ERR! gyp info using node-gyp@9.0.0 npm ERR! gyp info using node@18.1.0 | win32 | x64 npm ERR! gyp info find Python using Python version 3.10.4 found at "C:\Program Files\Python310\python.exe" npm ERR! gyp info find VS using VS2022 (17.2.32505.173) found at: npm ERR! gyp info find VS "C:\Program Files\Microsoft Visual Studio\2022\Community" npm ERR! gyp info find VS run with --verbose for detailed information npm ERR! gyp info spawn C:\Program Files\Python310\python.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\gyp\\gyp_main.py', npm ERR! gyp info spawn args 'binding.gyp', npm ERR! gyp info spawn args '-f', npm ERR! gyp info spawn args 'msvs', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'N:\\testenv\\test\\node_modules\\gatsby\\node_modules\\gatsby\\node_modules\\lmdb\\build\\config.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp\\addon.gypi', npm ERR! gyp info spawn args '-I', npm ERR! gyp info spawn args 'C:\\Users\\user\\AppData\\Local\\node-gyp\\Cache\\18.1.0\\include\\node\\common.gypi', npm ERR! gyp info spawn args '-Dlibrary=shared_library', npm ERR! gyp info spawn args '-Dvisibility=default', npm ERR! gyp info spawn args '-Dnode_root_dir=C:\\Users\\user\\AppData\\Local\\node-gyp\\Cache\\18.1.0', npm ERR! gyp info spawn args '-Dnode_gyp_dir=C:\\Users\\user\\AppData\\Roaming\\npm\\node_modules\\npm\\node_modules\\node-gyp', npm ERR! gyp info spawn args '-Dnode_lib_file=C:\\\\Users\\\\user\\\\AppData\\\\Local\\\\node-gyp\\\\Cache\\\\18.1.0\\\\<(target_arch)\\\\node.lib', npm ERR! gyp info spawn args '-Dmodule_root_dir=N:\\testenv\\test\\node_modules\\gatsby\\node_modules\\gatsby\\node_modules\\lmdb', npm ERR! gyp info spawn args '-Dnode_engine=v8', npm ERR! gyp info spawn args '--depth=.', npm ERR! gyp info spawn args '--no-parallel', npm ERR! gyp info spawn args '--generator-output', npm ERR! gyp info spawn args 'N:\\testenv\\test\\node_modules\\gatsby\\node_modules\\gatsby\\node_modules\\lmdb\\build', npm ERR! gyp info spawn args '-Goutput_dir=.' npm ERR! gyp info spawn args ] npm ERR! gyp info spawn C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe npm ERR! gyp info spawn args [ npm ERR! gyp info spawn args 'build/binding.sln', npm ERR! gyp info spawn args '/clp:Verbosity=minimal', npm ERR! gyp info spawn args '/nologo', npm ERR! gyp info spawn args '/p:Configuration=Release;Platform=x64' npm ERR! gyp info spawn args ] npm ERR! gyp ERR! build error npm ERR! gyp ERR! stack Error:C:\Program Files\Microsoft Visual Studio\2022\Community\MSBuild\Current\Bin\MSBuild.exe` failed with exit code: 1 npm ERR! gyp ERR! stack at ChildProcess.onExit (C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\lib\build.js:194:23) npm ERR! gyp ERR! stack at ChildProcess.emit (node:events:527:28) npm ERR! gyp ERR! stack at ChildProcess._handle.onexit (node:internal/child_process:291:12) npm ERR! gyp ERR! System Windows_NT 10.0.22000 npm ERR! gyp ERR! command "C:\Program Files\nodejs\node.exe" "C:\Users\user\AppData\Roaming\npm\node_modules\npm\node_modules\node-gyp\bin\node-gyp.js" "rebuild" npm ERR! gyp ERR! cwd N:\testenv\test\node_modules\gatsby\node_modules\gatsby\node_modules\lmdb npm ERR! gyp ERR! node -v v18.1.0 npm ERR! gyp ERR! node-gyp -v v9.0.0 npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in: npm ERR! C:\Users\user\AppData\Local\npm-cache_logs\2022-05-14T22_44_18_833Z-debug-0.log`

Alexyoe commented 2 years ago

I'm having the same issue as @paulober. After updating to Node v18.1.0 I get the same error. I tried running gatsby clean and removing node_modules but now I can no longer even install the package.json without it erroring out.

Zailef commented 2 years ago

I have tested this with Node v18.1.0 and ran into some of the issues outlined above, however, these are problems building some of the package dependencies from source. After installing Python and Visual Studio 2022's 'Desktop development with C++' workload I was able to build the problem dependencies and use Gatsby with Node 18. Hopefully it won't be too long before pre-built versions of these packages are available for popular setups since most people won't be expecting to build from source.

BurkovBA commented 2 years ago

I'm using Node.js 16.15.0 and Gatsby 4.13.1 on Alpine (building in Docker from node:16-alpine base image).

Today ran into an error with node-gyp and lmdb, which didn't exist on May 15th:

npm notice 
npm ERR! code 1
npm ERR! path /srv/node_modules/lmdb
npm ERR! command failed
npm ERR! command sh -c node-gyp-build-optional-packages
npm ERR! make: Entering directory '/srv/node_modules/lmdb/build'
npm ERR! make: Leaving directory '/srv/node_modules/lmdb/build'
npm ERR! gyp info it worked if it ends with ok
npm ERR! gyp info using node-gyp@8.4.1
npm ERR! gyp info using node@16.15.0 | linux | x64
npm ERR! gyp info find Python using Python version 3.9.7 found at "/usr/bin/python3"
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.15.0/node-v16.15.0-headers.tar.gz
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.15.0/node-v16.15.0-headers.tar.gz
npm ERR! gyp http GET https://unofficial-builds.nodejs.org/download/release/v16.15.0/SHASUMS256.txt
npm ERR! gyp http 200 https://unofficial-builds.nodejs.org/download/release/v16.15.0/SHASUMS256.txt
npm ERR! gyp info spawn /usr/bin/python3
npm ERR! gyp info spawn args [
npm ERR! gyp info spawn args   '/srv/node_modules/node-gyp/gyp/gyp_main.py',
npm ERR! gyp info spawn args   'binding.gyp',
npm ERR! gyp info spawn args   '-f',
npm ERR! gyp info spawn args   'make',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/srv/node_modules/lmdb/build/config.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/srv/node_modules/node-gyp/addon.gypi',
npm ERR! gyp info spawn args   '-I',
npm ERR! gyp info spawn args   '/root/.cache/node-gyp/16.15.0/include/node/common.gypi',
npm ERR! gyp info spawn args   '-Dlibrary=shared_library',
npm ERR! gyp info spawn args   '-Dvisibility=default',
npm ERR! gyp info spawn args   '-Dnode_root_dir=/root/.cache/node-gyp/16.15.0',
npm ERR! gyp info spawn args   '-Dnode_gyp_dir=/srv/node_modules/node-gyp',
npm ERR! gyp info spawn args   '-Dnode_lib_file=/root/.cache/node-gyp/16.15.0/<(target_arch)/node.lib',
npm ERR! gyp info spawn args   '-Dmodule_root_dir=/srv/node_modules/lmdb',
npm ERR! gyp info spawn args   '-Dnode_engine=v8',
npm ERR! gyp info spawn args   '--depth=.',
npm ERR! gyp info spawn args   '--no-parallel',
npm ERR! gyp info spawn args   '--generator-output',
npm ERR! gyp info spawn args   'build',
npm ERR! gyp info spawn args   '-Goutput_dir=.'
npm ERR! gyp info spawn args ]
npm ERR! gyp info spawn make
npm ERR! gyp info spawn args [ 'BUILDTYPE=Release', '-C', 'build' ]
npm ERR! make: printf: Operation not permitted
npm ERR! make: *** [lmdb.target.mk:159: Release/obj.target/lmdb/src/lmdb-js.o] Error 127
npm ERR! gyp ERR! build error 
npm ERR! gyp ERR! stack Error: `make` failed with exit code: 2
npm ERR! gyp ERR! stack     at ChildProcess.onExit (/srv/node_modules/node-gyp/lib/build.js:194:23)
npm ERR! gyp ERR! stack     at ChildProcess.emit (node:events:527:28)
npm ERR! gyp ERR! stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:291:12)
npm ERR! gyp ERR! System Linux 4.9.0-17-amd64
npm ERR! gyp ERR! command "/usr/local/bin/node" "/srv/node_modules/.bin/node-gyp" "rebuild"
npm ERR! gyp ERR! cwd /srv/node_modules/lmdb
npm ERR! gyp ERR! node -v v16.15.0
npm ERR! gyp ERR! node-gyp -v v8.4.1
npm ERR! gyp ERR! not ok

npm ERR! A complete log of this run can be found in:
npm ERR!     /root/.npm/_logs/2022-05-28T18_01_41_481Z-debug-0.log
The command '/bin/sh -c npm install' returned a non-zero code: 1
LekoArts commented 2 years ago

This should be fixed with https://github.com/gatsbyjs/gatsby/pull/35782 - you can try gatsby@next or wait until June 7 for 4.16 release.

LeoMrel commented 2 years ago

Hi @paulober 👋

Can you please try out gatsby@next (e.g. with npm install gatsby@next) as it contains an updated lmdb version. Thanks!

This worked for me, had to use npm install gatsby@next --legacy-peer-deps flag tho!

saramartz commented 7 months ago

Having the same issue with Node v20.11.0, even if I try to install gatsby@next I get an error with gatsby-plugin-image

lta4 commented 7 months ago

I'm having the same issue as @saramartz. With Node v20.0.0 and React 18.2.0, installing gatsby@next is still throwing error gatsby-plugin-image