Gatsby 开发总是在 Windows 上失败
Gatsby develop always failing on Windows
我想我会试一试 Gatsby 和 Gatsby Cloud,但是它从来没有设法在本地 运行,但是云部署构建并且 运行 很好。
我经常运行在使用this guide
时遇到node-gyp
找不到模块错误
我已经阅读了 Gatsby On Windows 和 Microsoft Windows VS-Build 环境指南。我目前在我的机器上安装了 VS-2015/2017/2019/2022 Python 2.7 和 3,NodeJS 版本是最新的 (18.x),我已经尝试使用当前的 LTS (16.x)
我使用 Bash Shell 和
我试过:
$ npm r -g node-gyp node-gyp-build gatsby-cli
$ npm config set msvs_version 2022
$ npm config set python python2.7
$ npm cache clean -f
$ npm i -g gatsby-cli
然后 gatsby develop
仍然会出错。所以我尝试了 npm i -g node-gyp-build node-gyp
.
仍然出错,所以我在不同的 VS-build 工具版本上尝试了同样的方法,没有改进。
错误日志:
OS: Windows 10 (10.0.19043) | x64 | Intel(R) Core(TM) i3-8145U CPU @ 2.10GHz x 4
Node version: v16.14.2
NPM version: 8.5.5
Gatsby CLI version: 4.13.0
Gatsby version: 4.13.1
Note: this is the Gatsby version for the site at:
${USER}${PATH}
gatsby develop
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'node-gyp-build'
Require stack:
- ${USER}
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (${USER}${PATH}\node_modules\lmdb\node-index.js:17:20)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\Users\${USER}' ]
}
以上结果是我切换到 NVM
并更新为 16.15
和 18.1.0
之前的结果
与最新的 NodeJS(在 react
和 grommet
处出现错误)和 NodeJS LTS(当前补丁:16.15
)的结果相同。全部在 x64 arch
.
我试过强制 $ npm audit -f
,这没有解决任何问题 $ npm outdated && npm update
。
老实说,我没有想法。
我从二进制安装程序而不是通过巧克力或 NVM 将 NodeJS 重新安装到 LTS 版本,这并没有改变任何东西。然而,我在我当前的一次性笔记本电脑上的用户名不小心在路径中有一个 #
。我对注册表进行了编辑并重新定义了我的 $PATH 和环境变量。 #
似乎打破了 node module
.
的路径
有趣的怪癖。
我想我会试一试 Gatsby 和 Gatsby Cloud,但是它从来没有设法在本地 运行,但是云部署构建并且 运行 很好。
我经常运行在使用this guide
时遇到node-gyp
找不到模块错误
我已经阅读了 Gatsby On Windows 和 Microsoft Windows VS-Build 环境指南。我目前在我的机器上安装了 VS-2015/2017/2019/2022 Python 2.7 和 3,NodeJS 版本是最新的 (18.x),我已经尝试使用当前的 LTS (16.x)
我使用 Bash Shell 和 我试过:
$ npm r -g node-gyp node-gyp-build gatsby-cli
$ npm config set msvs_version 2022
$ npm config set python python2.7
$ npm cache clean -f
$ npm i -g gatsby-cli
然后 gatsby develop
仍然会出错。所以我尝试了 npm i -g node-gyp-build node-gyp
.
仍然出错,所以我在不同的 VS-build 工具版本上尝试了同样的方法,没有改进。
错误日志:
OS: Windows 10 (10.0.19043) | x64 | Intel(R) Core(TM) i3-8145U CPU @ 2.10GHz x 4
Node version: v16.14.2
NPM version: 8.5.5
Gatsby CLI version: 4.13.0
Gatsby version: 4.13.1
Note: this is the Gatsby version for the site at:
${USER}${PATH}
gatsby develop
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'node-gyp-build'
Require stack:
- ${USER}
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (${USER}${PATH}\node_modules\lmdb\node-index.js:17:20)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [ 'C:\Users\${USER}' ]
}
以上结果是我切换到 NVM
并更新为 16.15
和 18.1.0
之前的结果
与最新的 NodeJS(在 react
和 grommet
处出现错误)和 NodeJS LTS(当前补丁:16.15
)的结果相同。全部在 x64 arch
.
我试过强制 $ npm audit -f
,这没有解决任何问题 $ npm outdated && npm update
。
老实说,我没有想法。
我从二进制安装程序而不是通过巧克力或 NVM 将 NodeJS 重新安装到 LTS 版本,这并没有改变任何东西。然而,我在我当前的一次性笔记本电脑上的用户名不小心在路径中有一个 #
。我对注册表进行了编辑并重新定义了我的 $PATH 和环境变量。 #
似乎打破了 node module
.
有趣的怪癖。