Max*_*ler 7 npm gatsby yarnpkg
我正在尝试在 Windows 上建立一个 Gatsby 入门项目。具体来说,这个入门项目:https://www.gatsbyjs.com/starters/hasura/gatsby-gitbook-starter/
\n节点:v14.10.1\nnpm:6.14.8\nGatsby CLI 版本:2.12.99\nGatsby 版本:2.18.10
\n我打开一个新终端并根据文档运行 Gatsby Starter 脚本:
\n"gatsby new gatsby-gitbook-starter https://github.com/hasura/gatsby-gitbook-starter"\nRun Code Online (Sandbox Code Playgroud)\n成功克隆初始启动程序后,系统指示我 cd 进入该目录并运行“gatsby-develop”。
\n这会引发以下错误:
\nsuccess open and validate gatsby-configs - 0.081s\n\n ERROR \n\n\nSomething went wrong installing the "sharp" module\n\nCannot find module \'../build/Release/sharp.node\'\nRequire stack:\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\sharp\\lib\\constructor.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\sharp\\lib\\index.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby-plugin-sharp\\safe-sharp.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby-plugin-sharp\\index.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby-plugin-sharp\\gatsby-node.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby\\dist\\bootstrap\\resolve-module-exports.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby\\dist\\bootstrap\\load-plugins\\validate.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby\\dist\\bootstrap\\load-plugins\\load.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby\\dist\\bootstrap\\load-plugins\\index.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby\\dist\\bootstrap\\index.js\n- C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\gatsby\\dist\\commands\\develop.js\n- C:\\Users\\mxgel\\AppData\\Roaming\\npm\\node_modules\\gatsby-cli\\lib\\create-cli.js\n- C:\\Users\\mxgel\\AppData\\Roaming\\npm\\node_modules\\gatsby-cli\\lib\\index.js\n- C:\\Users\\mxgel\\AppData\\Roaming\\npm\\node_modules\\gatsby-cli\\cli.js\n\n- Remove the "node_modules/sharp" directory, run "npm install" and look for errors\n- Consult the installation documentation at https://sharp.pixelplumbing.com/en/stable/install/\n- Search for this error at https://github.com/lovell/sharp/issues\n\n\n\xe2\xa0\x8b load plugins\nRun Code Online (Sandbox Code Playgroud)\n我的预感是,这个错误是由于一些我无法弄清楚的全局包管理器配置而引发的,而不是 Sharp 依赖项本身。我的目标是使用这个 Gatsby starter 来简化项目文档的流程。
\n我的第一步是尝试错误本身抛出的建议。
\n我尝试删除 node_modules/sharp 目录并运行 npm install 但它没有给我任何错误,也没有解决问题。NPM 安装的输出如下。
\nadded 2 packages from 60 contributors and audited 2713 packages in 12.906s\n\n54 packages are looking for funding\n run `npm fund` for details\n\nfound 1219 vulnerabilities (1168 low, 2 moderate, 49 high)\n run `npm audit fix` to fix them, or `npm audit` for details\nRun Code Online (Sandbox Code Playgroud)\n假设“verbose”标志会有所帮助,我删除了模块和 package-lock.json 并运行 npm install Sharp --verbose:
\nnpm info it worked if it ends with ok\nnpm verb cli [\nnpm verb cli \'C:\\\\nodejs\\\\node.exe\',\nnpm verb cli \'C:\\\\Users\\\\mxgel\\\\AppData\\\\Roaming\\\\npm\\\\node_modules\\\\npm\\\\bin\\\\npm-cli.js\',\nnpm verb cli \'install\',\nnpm verb cli \'sharp\',\nnpm verb cli \'--verbose\'\nnpm verb cli ]\nnpm info using npm@6.14.8\nnpm info using node@v14.10.1\nnpm verb npm-session 166ad6819380c39e\nnpm http fetch GET 304 https://registry.npmjs.org/sharp 240ms (from cache)\nnpm http fetch GET 200 https://registry.npmjs.org/sharp/-/sharp-0.26.1.tgz 103ms (from cache)\nnpm timing stage:loadCurrentTree Completed in 3562ms\nnpm timing stage:loadIdealTree:cloneCurrentTree Completed in 44ms\nnpm timing stage:loadIdealTree:loadShrinkwrap Completed in 938ms\nnpm http fetch GET 304 https://registry.npmjs.org/semver 85ms (from cache)\nnpm http fetch GET 304 https://registry.npmjs.org/fsevents 114ms (from cache)\nnpm WARN deprecated fsevents@1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.\nnpm http fetch GET 304 https://registry.npmjs.org/bindings 145ms (from cache)\nnpm http fetch GET 304 https://registry.npmjs.org/file-uri-to-path 101ms (from cache)\nnpm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 8627ms\nnpm timing stage:loadIdealTree Completed in 10371ms\nnpm timing stage:generateActionsToTake Completed in 190ms\nnpm verb correctMkdir C:\\Users\\mxgel\\AppData\\Roaming\\npm-cache\\_locks correctMkdir not in flight; initializing\nnpm verb makeCacheDir UID & GID are irrelevant on win32\nnpm verb lock using C:\\Users\\mxgel\\AppData\\Roaming\\npm-cache\\_locks\\staging-cfcdc7ee6147183b.lock for C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\.staging\nnpm timing action:extract Completed in 291ms\nnpm timing audit submit Completed in 321ms\nnpm http fetch POST 200 https://registry.npmjs.org/-/npm/v1/security/audits/quick 324ms\nnpm timing audit body Completed in 4ms\nnpm timing action:finalize Completed in 19ms\nnpm timing action:refresh-package-json Completed in 93ms\nnpm info lifecycle file-uri-to-path@1.0.0~preinstall: file-uri-to-path@1.0.0\nnpm info lifecycle bindings@1.5.0~preinstall: bindings@1.5.0\nnpm info lifecycle semver@7.3.2~preinstall: semver@7.3.2\nnpm info lifecycle sharp@0.26.1~preinstall: sharp@0.26.1\nnpm timing action:preinstall Completed in 7ms\nnpm info linkStuff file-uri-to-path@1.0.0\nnpm info linkStuff bindings@1.5.0\nnpm info linkStuff semver@7.3.2\nnpm verb linkBins [\nnpm verb linkBins { semver: \'bin/semver.js\' },\nnpm verb linkBins \'C:\\\\code\\\\Sutro\\\\gatsby-gitbook-starter2\\\\node_modules\\\\sharp\\\\node_modules\\\\.bin\',\nnpm verb linkBins false\nnpm verb linkBins ]\nnpm info linkStuff sharp@0.26.1\nnpm timing action:build Completed in 68ms\nnpm info lifecycle file-uri-to-path@1.0.0~install: file-uri-to-path@1.0.0\nnpm info lifecycle bindings@1.5.0~install: bindings@1.5.0\nnpm info lifecycle semver@7.3.2~install: semver@7.3.2\nnpm info lifecycle sharp@0.26.1~install: sharp@0.26.1\nnpm info lifecycle sharp@0.26.1~install: ignored because ignore-scripts is set to true sharp@0.26.1\nnpm timing action:install Completed in 32ms\nnpm info lifecycle file-uri-to-path@1.0.0~postinstall: file-uri-to-path@1.0.0\nnpm info lifecycle bindings@1.5.0~postinstall: bindings@1.5.0\nnpm info lifecycle semver@7.3.2~postinstall: semver@7.3.2\nnpm info lifecycle sharp@0.26.1~postinstall: sharp@0.26.1\nnpm timing action:postinstall Completed in 46ms\nnpm verb unlock done using C:\\Users\\mxgel\\AppData\\Roaming\\npm-cache\\_locks\\staging-cfcdc7ee6147183b.lock for C:\\code\\Sutro\\gatsby-gitbook-starter2\\node_modules\\.staging\nnpm timing stage:executeActions Completed in 648ms\nnpm timing stage:rollbackFailedOptional Completed in 1ms\nnpm timing stage:runTopLevelLifecycles Completed in 15394ms\nnpm verb saving [ { name: \'sharp\', spec: \'^0.26.1\', save: \'dependencies\' } ]\nnpm verb shrinkwrap skipping write for package.json because there were no changes.\nnpm info lifecycle undefined~preshrinkwrap: undefined\nnpm info lifecycle gatsby-gitbook-boilerplate@0.0.1~shrinkwrap: gatsby-gitbook-boilerplate@0.0.1\nnpm notice created a lockfile as package-lock.json. You should commit this file.\nnpm info lifecycle gatsby-gitbook-boilerplate@0.0.1~postshrinkwrap: gatsby-gitbook-boilerplate@0.0.1\nnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.2.7 (node_modules\\babel-plugin-add-module-exports\\node_modules\\chokidar\\node_modules\\fsevents):\nnpm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64\nnpm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.1 (node_modules\\chokidar\\node_modules\\fsevents):\nnpm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS: darwin\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch: any\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS: win32\nnpm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64\nnpm WARN acorn-class-fields@0.2.1 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.\nnpm WARN acorn-dynamic-import@4.0.0 requires a peer of acorn@^6.0.0 but none is installed. You must install peer dependencies yourself.\nnpm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must \ninstall peer dependencies yourself.\n\n+ sharp@0.26.1\nadded 4 packages from 66 contributors and audited 2666 packages in 16.799s\n\n60 packages are looking for funding\n run `npm fund` for details\n\nfound 1206 vulnerabilities (1157 low, 2 moderate, 47 high)\n run `npm audit fix` to fix them, or `npm audit` for details\nnpm verb exit [ 0, true ]\nnpm timing npm Completed in 18411ms\nnpm info ok\nRun Code Online (Sandbox Code Playgroud)\n经过一番研究,我发现忽略脚本可能是问题所在。我尝试使用以下命令将忽略脚本设置为 true:
\nnpm install sharp --ignore-scripts\nRun Code Online (Sandbox Code Playgroud)\n这仍然没有解决问题,并引发了同样的错误。
\n我尝试删除整个节点模块文件夹和 package-lock.json,然后执行以下命令:
\nnpm install --unsafe-perm\nRun Code Online (Sandbox Code Playgroud)\n使用“gatsbydevelop”后仍然抛出尖锐错误
\n更多研究。再次尝试查看是否与 NPM 有关,我运行了以下命令,但无济于事:
\nnpm rebuild\nRun Code Online (Sandbox Code Playgroud)\n删除所有模块并使用纱线重试整个过程并没有解决问题。我列出这一点只是为了说明我的绝望。我可以发布一些纱线结果,但长话短说,在使用纱线安装方法时,夏普模块直接拒绝让我从夏普模块下载某个包。我什至能够追踪到拒绝下载的确切 tvg 模块,但我没有办法解决这个问题。
\n再次感谢您的时间和耐心,信息会有所帮助!
\n@Ferran 为我指出了最好的方向:Gatsby 文档。
不确定是什么导致了这个错误,但我完全重置了 Windows 10,然后从头开始重新安装了 Node、NPM、Gatsby。
现在所有命令都工作正常,没有严重的模块错误!我的驱动器上肯定存在一些环境冲突。
| 归档时间: |
|
| 查看次数: |
1551 次 |
| 最近记录: |