Netlify构建:bash:gatsby:找不到命令

时间:2020-08-16 13:19:23

标签: reactjs gatsby netlify

基于netlify的Gatsby曾经可以正常运行,但是突然停止了工作。它在本地构建,但在netlify上返回错误bash: gatsby: command not found

我已经尝试过的:

  • 将构建命令更改为“ npm run build”;
  • 将node / yarn / npm版本设置为环境变量;
  • 使用卷装锁和纱线锁进行部署(不能同时进行);

到资源库的链接:https://github.com/ramosht/ramosht.com

日志:

10:08:50 AM: Build ready to start
10:08:52 AM: build-image version: b0258b965567defc4a2d7e2f2dec2e00c8f73ad6
10:08:52 AM: build-image tag: v3.4.1
10:08:52 AM: buildbot version: 9042ba4998dab698f1f37fb8d36912c08a387191
10:08:52 AM: Building without cache
10:08:52 AM: Starting to prepare the repo for build
10:08:52 AM: No cached dependencies found. Cloning fresh repo
10:08:52 AM: git clone https://github.com/ramosht/ramosht
10:08:52 AM: Preparing Git Reference refs/heads/master
10:08:54 AM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'public' versus 'public/' in the Netlify UI
10:08:54 AM: Starting build script
10:08:54 AM: Installing dependencies
10:08:54 AM: Python version set to 2.7
10:08:55 AM: Downloading and installing node v10.22.0...
10:08:55 AM: Downloading https://nodejs.org/dist/v10.22.0/node-v10.22.0-linux-x64.tar.xz...
10:08:55 AM: Computing checksum with sha256sum
10:08:55 AM: Checksums matched!
10:08:58 AM: Now using node v10.22.0 (npm v6.14.6)
10:08:58 AM: Started restoring cached build plugins
10:08:58 AM: Finished restoring cached build plugins
10:08:58 AM: Attempting ruby version 2.6.2, read from environment
10:08:59 AM: Using ruby version 2.6.2
10:09:00 AM: Using PHP version 5.6
10:09:00 AM: 5.2 is already installed.
10:09:00 AM: Using Swift version 5.2
10:09:00 AM: Started restoring cached go cache
10:09:00 AM: Finished restoring cached go cache
10:09:00 AM: Installing Go version 1.12
10:09:05 AM: unset GOOS;
10:09:05 AM: unset GOARCH;
10:09:05 AM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64';
10:09:05 AM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.12.linux.amd64/bin:${PATH}";
10:09:05 AM: go version >&2;
10:09:05 AM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.12.linux.amd64.env"
10:09:05 AM: go version go1.12 linux/amd64
10:09:05 AM: Installing missing commands
10:09:05 AM: Verify run directory
10:09:06 AM: ​
10:09:06 AM: ┌─────────────────────────────┐
10:09:06 AM: │        Netlify Build        │
10:09:06 AM: └─────────────────────────────┘
10:09:06 AM: ​
10:09:06 AM: ❯ Version
10:09:06 AM:   @netlify/build 3.1.10
10:09:06 AM: ​
10:09:06 AM: ❯ Flags
10:09:06 AM:   deployId: 5f392fe2ad43c45468a78a0b
10:09:06 AM:   mode: buildbot
10:09:06 AM:   timersFile: /tmp/substage_times.txt
10:09:06 AM: ​
10:09:06 AM: ❯ Current directory
10:09:06 AM:   /opt/build/repo
10:09:06 AM: ​
10:09:06 AM: ❯ Config file
10:09:06 AM:   No config file was defined: using default values.
10:09:06 AM: ​
10:09:06 AM: ❯ Context
10:09:06 AM:   production
10:09:06 AM: ​
10:09:06 AM: ┌───────────────────────────────────┐
10:09:06 AM: │ 1. Build command from Netlify app │
10:09:06 AM: └───────────────────────────────────┘
10:09:06 AM: ​
10:09:06 AM: $ gatsby builud
10:09:06 AM: bash: gatsby: command not found
10:09:06 AM: ​
10:09:06 AM: ┌─────────────────────────────┐
10:09:06 AM: │   "build.command" failed    │
10:09:06 AM: └─────────────────────────────┘
10:09:06 AM: ​
10:09:06 AM:   Error message
10:09:06 AM:   Command failed with exit code 127: gatsby builud
10:09:06 AM: ​
10:09:06 AM:   Error location
10:09:06 AM:   In Build command from Netlify app:
10:09:06 AM:   gatsby builud
10:09:06 AM: ​
10:09:06 AM:   Resolved config
10:09:06 AM:   build:
10:09:06 AM:     command: gatsby builud
10:09:06 AM:     commandOrigin: ui
10:09:06 AM:     environment:
10:09:06 AM:       - GOOGLE_ANALYTICS_TRACKING_ID
10:09:06 AM:     publish: /opt/build/repo/public
10:09:06 AM: Caching artifacts
10:09:06 AM: Started saving build plugins
10:09:06 AM: Finished saving build plugins
10:09:06 AM: Started saving pip cache
10:09:06 AM: Finished saving pip cache
10:09:06 AM: Started saving emacs cask dependencies
10:09:06 AM: Finished saving emacs cask dependencies
10:09:06 AM: Started saving maven dependencies
10:09:06 AM: Finished saving maven dependencies
10:09:06 AM: Started saving boot dependencies
10:09:06 AM: Finished saving boot dependencies
10:09:07 AM: Started saving go dependencies
10:09:08 AM: Finished saving go dependencies
10:09:11 AM: Error running command: Build script returned non-zero exit code: 1
10:09:11 AM: Failing build: Failed to build site
10:09:11 AM: Failed during stage 'building site': Build script returned non-zero exit code: 1
10:09:11 AM: Finished processing build request in 19.80318381s

package.json

{
  "name": "gatsby-starter-default",
  "private": true,
  "description": "",
  "version": "0.1.0",
  "author": "Guilherme Rmos <contato@ramosht.com>",
  "dependencies": {
    "@weknow/gatsby-remark-codepen": "^0.1.0",
    "babel-preset-gatsby": "^0.5.1",
    "date-fns": "^2.14.0",
    "gatsby": "^2.19.43",
    "gatsby-cli": "^2.12.60",
    "gatsby-image": "^2.2.43",
    "gatsby-plugin-canonical-urls": "^2.3.0",
    "gatsby-plugin-google-analytics": "^2.3.0",
    "gatsby-plugin-manifest": "^2.2.47",
    "gatsby-plugin-netlify-cms": "^4.3.0",
    "gatsby-plugin-offline": "3.0.40",
    "gatsby-plugin-react-helmet": "^3.1.23",
    "gatsby-plugin-sharp": "^2.4.12",
    "gatsby-plugin-sitemap": "^2.4.1",
    "gatsby-plugin-styled-components": "^3.1.21",
    "gatsby-remark-images": "^3.3.0",
    "gatsby-remark-lazy-load": "^1.0.2",
    "gatsby-remark-prismjs": "3.3.5",
    "gatsby-remark-relative-images": "^0.3.0",
    "gatsby-remark-relative-images-v2": "^0.1.5",
    "gatsby-source-filesystem": "^2.1.55",
    "gatsby-transformer-json": "^2.4.10",
    "gatsby-transformer-remark": "^2.8.23",
    "gatsby-transformer-sharp": "^2.3.18",
    "lazysizes": "^5.2.0",
    "netlify-cms-app": "^2.12.11",
    "prismjs": "1.17.1",
    "prop-types": "^15.7.2",
    "react": "^16.12.0",
    "react-animated-burgers": "^1.2.7",
    "react-disqus-comments": "^1.4.0",
    "react-dom": "^16.12.0",
    "react-helmet": "^5.2.1",
    "react-responsive": "^8.1.0",
    "save": "^2.4.0",
    "styled-components": "^4.3.2",
    "styled-icons": "^10.2.1",
    "uuidv4": "^6.1.1"
  },
  "devDependencies": {
    "prettier": "^1.19.1"
  },
  "keywords": [
    "gatsby"
  ],
  "license": "MIT",
  "scripts": {
    "build": "gatsby build",
    "develop": "gatsby develop",
    "format": "prettier --write \"**/*.{js,jsx,json,md}\"",
    "start": "npm run develop",
    "serve": "gatsby serve",
    "clean": "gatsby clean",
    "test": "echo \"Write tests! -> https://gatsby.dev/unit-testing\" && exit 1"
  },
  "repository": {
    "type": "git",
    "url": "https://github.com/gatsbyjs/gatsby-starter-default"
  },
  "bugs": {
    "url": "https://github.com/gatsbyjs/gatsby/issues"
  }
}

3 个答案:

答案 0 :(得分:1)

在npm构建过程和解决方案中,我经历了很多次:

  1. 运行:set NODE_OPTIONS =-max_old_space_size = 4096
  2. 删除node_modules
  3. 运行:npm install
  4. 运行:yarn install(如果正在使用)
  5. 运行:npm运行构建

我的方法不确定对您有用,但请尝试一下。

我希望会..

答案 1 :(得分:0)

Command failed with exit code 127: gatsby builud

也:

10:09:06 AM:   Error location
10:09:06 AM:   In Build command from Netlify app:
10:09:06 AM:   gatsby builud

发现错字builud,而不是build。您必须在Netlify的仪表板中的部署命令中遇到问题。

答案 2 :(得分:0)

如果你想在 netlify 的构建过程中运行任何 yarn 命令,那么在你的根目录中包含 yarn.lock。即使是一个空的 yarn.lock 文件也能正常工作。