我试图将一个站点部署到Netlify,但遇到了这个错误
10:22:38 PM: Error: Cannot find module 'gatsby-plugin-image/graphql-utils'
我在这里查看了并看到了运行此命令的解决方案
node -v > nvmrc
我运行了命令并开始了新的部署。在部署过程中,出现了另一个错误
10:29:38 PM: Build ready to start
10:29:40 PM: build-image version: e4d2dbe4cfec46db257e869258461ded89b75c9b
10:29:40 PM: build-image tag: v3.7.3
10:29:40 PM: buildbot version: 2cb5794cb93042dadefe5dbdc6b35edc34c20454
10:29:40 PM: Fetching cached dependencies
10:29:40 PM: Failed to fetch cache, continuing with build
10:29:40 PM: Starting to prepare the repo for build
10:29:40 PM: No cached dependencies found. Cloning fresh repo
10:29:40 PM: git clone https://github.com/Dayropo/gatsby-exercise
10:29:41 PM: Preparing Git Reference refs/heads/master
10:29:42 PM: Parsing package.json dependencies
10:29:43 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
10:29:43 PM: Starting build script
10:29:43 PM: Installing dependencies
10:29:43 PM: Python version set to 2.7
10:29:43 PM: Attempting node version 'v14.16.1
' from .nvmrc
10:29:44 PM: Version 'v14.16.1
' not found - try `nvm ls-remote` to browse available versions.
10:29:44 PM: Failed to install node version 'v14.16.1
'
10:29:44 PM: Build was terminated: Build script returned non-zero exit code: 1
10:29:44 PM: Creating deploy upload records
10:29:44 PM: Failing build: Failed to build site
10:29:44 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
10:29:44 PM: Finished processing build request in 4.627825827s
非常感谢您的帮助。
正如您所说,当某些依赖关系仅在Netlify端失败时,99%的情况是由本地和Netlify环境之间的Node版本不匹配引起的。这是通过强制使用以下的节点版本来修复的:
node -v > nvmrc
当Netlify找到.nvmrc
文件时,它会尝试下载该版本以启动构建过程,这是一个完美的解决方法,也是修复缺失依赖关系的方法。在您的情况下,Node版本无法满足(14.16.1
(,因此整个过程甚至无法启动。
Netlify的部署系统在构建期间下载Node和Node包,此问题主要与Netlify和Cloudflare之间的临时问题有关。
因此,如果您的应用程序在本地构建而没有任何问题,请不要惊慌,他们很快就会解决问题。几小时后重试部署,并查看Netlify状态页或Cloudflare状态页以获取更多日志。
根据Cloudflare的状态页面,他们似乎在全球的一些服务器上遇到了问题。
来源:
- https://answers.netlify.com/t/need-help-debugging-version-12-18-0-not-found-try-nvm-ls-remote-to-browse-available-versions/19067/13
- https://answers.netlify.com/t/deploy-failed-to-install-node-version-10/7322/3
- https://github.com/netlify/cli/issues/1163
- https://answers.netlify.com/t/building-issue-version-12-18-0-not-found-try-nvm-ls-remote-to-browse-available-versions/21630