我以為我會在 Gatsby 和 Gatsby Cloud 上有所作為,但它從來沒有設法在本地運行,但是云部署構建和運行得很好。
在使用本指南時,我經常遇到node-gyp找不到模塊錯誤
我已經閱讀了Gatsby On Windows和帶有 VS-Build 工具的 Microsoft Windows 環境指南。我目前使用 Python 2.7 和 3 在我的機器上安裝了 VS-2015/2017/2019/2022,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}' ]
}
上面的結果是在我切換到 aNVM并更新到16.15與18.1.0
NodeJS latest (錯誤本身在reactwith grommet)和 NodeJS LTS (當前補丁:)之前的結果相同16.15。全部在x64 arch.
我試過強迫$ npm audit -f,這并沒有解決任何問題,并且$ npm outdated && npm update.
老實說,我沒有想法。
uj5u.com熱心網友回復:
我從二進制安裝程式而不是通過巧克力或 NVM 將 NodeJS 重新安裝到 LTS 版本,這并沒有改變任何東西。但是,我當前的一次性筆記本電腦上的用戶名意外地出現#在路徑中。我對注冊表進行了編輯并重新定義了我的 $PATH 和環境變數。似乎#打破了通往node module.
有趣的怪癖。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qukuanlian/474708.html
