netlify build command failed (create react app)-locally deployed ok - netlify

I can't figure out why I can deploy perfectly locally but not working when I manually dropped the build folder online or add my repo with Github method. I got the error like below:
10:21:21 PM: Build ready to start 10:21:22 PM: build-image version:
d84c79427e8f83c1ba17bcdd7b3fe38059376b68 10:21:22 PM: build-image tag:
v3.6.1 10:21:22 PM: buildbot version:
44655717ddf0e7bd7f856f5b1154254de54b1d80 10:21:23 PM: Building without
cache 10:21:23 PM: Starting to prepare the repo for build 10:21:23 PM:
No cached dependencies found. Cloning fresh repo 10:21:23 PM: git
clone https://github.com/celinevalentine/Games 10:21:24 PM: Preparing
Git Reference refs/heads/celinev 10:21:26 PM: Different publish path
detected, going to use the one specified in the Netlify configuration
file: 'build' versus 'build/' in the Netlify UI 10:21:26 PM: Starting
build script 10:21:26 PM: Installing dependencies 10:21:26 PM: Python
version set to 2.7 10:21:27 PM: v12.18.0 is already installed.
10:21:28 PM: Now using node v12.18.0 (npm v6.14.4) 10:21:28 PM:
Started restoring cached build plugins 10:21:28 PM: Finished restoring
cached build plugins 10:21:28 PM: Attempting ruby version 2.7.1, read
from environment 10:21:29 PM: Using ruby version 2.7.1 10:21:29 PM:
Using PHP version 5.6 10:21:29 PM: Started restoring cached go cache
10:21:29 PM: Finished restoring cached go cache 10:21:29 PM: go
version go1.14.4 linux/amd64 10:21:29 PM: go version go1.14.4
linux/amd64 10:21:29 PM: Installing missing commands 10:21:29 PM:
Verify run directory 10:21:31 PM: ​ 10:21:31 PM:
────────────────────────────────────────────────────────────────
10:21:31 PM: Netlify Build
10:21:31 PM:
────────────────────────────────────────────────────────────────
10:21:31 PM: ​ 10:21:31 PM: ❯ Version 10:21:31 PM: #netlify/build
8.3.0 10:21:31 PM: ​ 10:21:31 PM: ❯ Flags 10:21:31 PM: deployId: 6014fae1970bcf9dcb4a28eb 10:21:31 PM: mode: buildbot 10:21:31 PM: ​
10:21:31 PM: ❯ Current directory 10:21:31 PM: /opt/build/repo
10:21:31 PM: ​ 10:21:31 PM: ❯ Config file 10:21:31 PM: No config
file was defined: using default values. 10:21:31 PM: ​ 10:21:31 PM: ❯
Context 10:21:31 PM: production 10:21:31 PM: ​ 10:21:31 PM:
────────────────────────────────────────────────────────────────
10:21:31 PM: 1. Build command from Netlify app
10:21:31 PM:
────────────────────────────────────────────────────────────────
10:21:31 PM: ​ 10:21:31 PM: $ npm run build 10:21:31 PM: npm ERR! code
ENOENT 10:21:31 PM: npm ERR! syscall open 10:21:31 PM: npm ERR! path
/opt/build/repo/package.json 10:21:31 PM: npm ERR! errno -2 10:21:31
PM: npm ERR! enoent ENOENT: no such file or directory, open
'/opt/build/repo/package.json' 10:21:31 PM: npm ERR! enoent This is
related to npm not being able to find a file. 10:21:31 PM: npm ERR!
enoent 10:21:31 PM: npm ERR! A complete log of this run can be found
in: 10:21:31 PM: npm ERR!
/opt/buildhome/.npm/_logs/2021-01-30T06_21_31_988Z-debug.log 10:21:32
PM: ​ 10:21:32 PM:
────────────────────────────────────────────────────────────────
10:21:32 PM: "build.command" failed
10:21:32 PM:
────────────────────────────────────────────────────────────────
10:21:32 PM: ​ 10:21:32 PM: Error message 10:21:32 PM: Command
failed with exit code 254: npm run build 10:21:32 PM: ​ 10:21:32 PM:
Error location 10:21:32 PM: In Build command from Netlify app:
10:21:32 PM: npm run build 10:21:32 PM: ​ 10:21:32 PM: Resolved
config 10:21:32 PM: build: 10:21:32 PM: command: npm run build
10:21:32 PM: commandOrigin: ui 10:21:32 PM: publish:
/opt/build/repo/build 10:21:32 PM: Caching artifacts 10:21:32 PM:
Started saving build plugins 10:21:32 PM: Finished saving build
plugins 10:21:32 PM: Started saving pip cache 10:21:32 PM: Finished
saving pip cache 10:21:32 PM: Started saving emacs cask dependencies
10:21:32 PM: Finished saving emacs cask dependencies 10:21:32 PM:
Started saving maven dependencies 10:21:32 PM: Finished saving maven
dependencies 10:21:32 PM: Started saving boot dependencies 10:21:32
PM: Finished saving boot dependencies 10:21:32 PM: Started saving rust
rustup cache 10:21:32 PM: Finished saving rust rustup cache 10:21:32
PM: Started saving go dependencies 10:21:32 PM: Finished saving go
dependencies 10:21:35 PM: Build failed due to a user error: Build
script returned non-zero exit code: 2 10:21:35 PM: Failing build:
Failed to build site 10:21:35 PM: Failed during stage 'building site':
Build script returned non-zero exit code: 2 10:21:35 PM: Finished
processing build request in 12.138963808s

Please try
CI= npm run build
instead of the
-> npm run build

Related

Why Netlify Run Time Error shows while deploying?

"scripts": {
"test": "echo "Error: no test specified" && exit 1",
"start": "nodemon index.js"
}
netlify shows
9:32:09 PM: build-image version: 01daab3416c9da7032f1dcdb8b1adffdaf5ccb74 (focal)
9:32:09 PM: buildbot version: 01daab3416c9da7032f1dcdb8b1adffdaf5ccb74
9:32:09 PM: Fetching cached dependencies
9:32:09 PM: Failed to fetch cache, continuing with build
9:32:09 PM: Starting to prepare the repo for build
9:32:10 PM: No cached dependencies found. Cloning fresh repo
9:32:10 PM: git clone --filter=blob:none https://github.com/abak02/medicine-shop
9:32:10 PM: Preparing Git Reference refs/heads/master
9:32:11 PM: Parsing package.json dependencies
9:32:12 PM: Starting build script
9:32:12 PM: Installing dependencies
9:32:12 PM: Python version set to 2.7
9:32:13 PM: v16.19.0 is already installed.
9:32:13 PM: Now using node v16.19.0 (npm v8.19.3)
9:32:13 PM: Enabling Node.js Corepack
9:32:13 PM: Started restoring cached build plugins
9:32:13 PM: Finished restoring cached build plugins
9:32:13 PM: Attempting Ruby version 2.7.2, read from environment
9:32:14 PM: Using Ruby version 2.7.2
9:32:14 PM: Using PHP version 8.0
9:32:14 PM: Started restoring cached corepack dependencies
9:32:14 PM: Finished restoring cached corepack dependencies
9:32:14 PM: No npm workspaces detected
9:32:14 PM: Started restoring cached node modules
9:32:14 PM: Finished restoring cached node modules
9:32:15 PM: Installing npm packages using npm version 8.19.3
9:32:17 PM: added 200 packages, and audited 201 packages in 2s
9:32:17 PM: 18 packages are looking for funding
9:32:17 PM: run npm fund for details
9:32:17 PM: found 0 vulnerabilities
9:32:17 PM: npm packages installed
9:32:17 PM: Started restoring cached go cache
9:32:17 PM: Finished restoring cached go cache
9:32:17 PM: go version go1.19.5 linux/amd64
9:32:17 PM: Detected 0 framework(s)
9:32:17 PM: Installing missing commands
9:32:17 PM: Verify run directory
9:32:17 PM: Section completed: initializing
9:32:19 PM: ​
9:32:19 PM: Netlify Build
9:32:19 PM: ────────────────────────────────────────────────────────────────
9:32:19 PM: ​
9:32:19 PM: ❯ Version
9:32:19 PM: #netlify/build 29.5.4
9:32:19 PM: ​
9:32:19 PM: ❯ Flags
9:32:19 PM: baseRelDir: true
9:32:19 PM: buildId: 63ea57f258aa1f2e036784c2
9:32:19 PM: deployId: 63ea57f258aa1f2e036784c4
9:32:19 PM: ​
9:32:19 PM: ❯ Current directory
9:32:19 PM: /opt/build/repo
9:32:19 PM: ​
9:32:19 PM: ❯ Config file
9:32:19 PM: No config file was defined: using default values.
9:32:19 PM: ​
9:32:19 PM: ❯ Context
9:32:19 PM: production
9:32:19 PM: ​
9:32:19 PM: 1. Build command from Netlify app
9:32:19 PM: ────────────────────────────────────────────────────────────────
9:32:19 PM: ​
9:32:19 PM: $ npm start
9:32:19 PM: > drug-website#1.0.0 start
9:32:19 PM: > nodemon index.js
9:32:19 PM: [nodemon] 2.0.20
9:32:19 PM: [nodemon] to restart at any time, enter rs
9:32:19 PM: [nodemon] watching path(s): .
9:32:19 PM: [nodemon] watching extensions: js,mjs,json
9:32:19 PM: [nodemon] starting node index.js
10:18:05 PM: Build exceeded maximum allowed runtime
Deploy a nodejs project but runtime error
9:32:19 PM: $ npm start
9:32:19 PM: drug-website#1.0.0 start
9:32:19 PM: nodemon index.js
9:32:19 PM: [nodemon] 2.0.20
9:32:19 PM: [nodemon] to restart at any time, enter rs
9:32:19 PM: [nodemon] watching path(s): .
9:32:19 PM: [nodemon] watching extensions: js,mjs,json
9:32:19 PM: [nodemon] starting node index.js
10:18:05 PM: Build exceeded maximum allowed runtime
The problem is in that part. Netlify is meant to run static apps. Your build process should run some commands and "exit" the process with some output. You can't run a server in the build process that waits for eternity.

Command failed with exit code 255: hugo (Hugo Netlify)

Went to deploy my site, it worked fine earlier today, but has now brought up this error. Anyone have any pointers? New to dealing with websites. I use the blogdown package in R and the theme LoveIt. The repository is on Git, and deploys via Netlify.
9:46:35 PM: ────────────────────────────────────────────────────────────────
9:46:35 PM: 1. build.command from netlify.toml
9:46:35 PM: ────────────────────────────────────────────────────────────────
9:46:35 PM: ​
9:46:35 PM: $ hugo
9:46:35 PM: Start building sites …
9:46:35 PM: hugo v0.101.0-466fa43c16709b4483689930a4f9ac8add5c9f66+extended linux/amd64 BuildDate=2022-06-16T07:09:16Z VendorInfo=gohugoio
9:46:35 PM: ERROR 2022/08/22 02:46:35 render of "page" failed: "/opt/build/repo/themes/LoveIt/layouts/posts/single.html:41:33": execute of template failed: template: posts/single.html:41:33: executing "content" at <.Params.categories>: range can't iterate over Research
Error: Error building site: failed to render pages: render of "home" failed: "/opt/build/repo/themes/LoveIt/layouts/index.html:36:20": execute of template failed: template: index.html:36:20: executing "content" at <.Render>: error calling Render: "/opt/build/repo/content/posts/mosquito-activity-and-weather/index.en.md:1:1": failed to execute template _default/summary.html: "/opt/build/repo/themes/LoveIt/layouts/_default/summary.html:41:25": execute of template failed: template: _default/summary.html:41:25: executing "_default/summary.html" at <.Params.categories>: range can't iterate over Research
Total in 236 ms
9:46:35 PM: ​
9:46:35 PM: ────────────────────────────────────────────────────────────────
9:46:35 PM: "build.command" failed
9:46:35 PM: ────────────────────────────────────────────────────────────────
9:46:35 PM: ​
9:46:35 PM: Error message
9:46:35 PM: Command failed with exit code 255: hugo (https://ntl.fyi/exit-code-255)
9:46:35 PM: ​
9:46:35 PM: Error location
9:46:35 PM: In build.command from netlify.toml:
9:46:35 PM: hugo
9:46:35 PM: ​
9:46:35 PM: Resolved config
9:46:35 PM: build:
9:46:35 PM: command: hugo
9:46:35 PM: commandOrigin: config
9:46:35 PM: environment:
9:46:35 PM: - HUGO_VERSION
9:46:35 PM: - NETLIFY_GRAPH_TOKEN
9:46:35 PM: - ONEGRAPH_AUTHLIFY_TOKEN
9:46:35 PM: - HUGO_ENV
9:46:35 PM: publish: /opt/build/repo/public
9:46:35 PM: publishOrigin: config
9:46:36 PM: Caching artifacts
9:46:36 PM: Started saving build plugins
9:46:36 PM: Finished saving build plugins
9:46:36 PM: Started saving pip cache
9:46:36 PM: Finished saving pip cache
9:46:36 PM: Started saving emacs cask dependencies
9:46:36 PM: Finished saving emacs cask dependencies
9:46:36 PM: Started saving maven dependencies
9:46:36 PM: Finished saving maven dependencies
9:46:36 PM: Started saving boot dependencies
9:46:36 PM: Finished saving boot dependencies
9:46:36 PM: Started saving rust rustup cache
9:46:36 PM: Finished saving rust rustup cache
9:46:36 PM: Started saving go dependencies
9:46:36 PM: Finished saving go dependencies
9:46:37 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:46:37 PM: Creating deploy upload records
9:46:37 PM: Failing build: Failed to build site
9:46:37 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:46:37 PM: Finished processing build request in 13.962789296s
In R, when I try to deploy the site locally, I get this error:
Launching the server via the command:
C:/Users/12045/AppData/Roaming/Hugo/0.101.0/hugo.exe server --bind 127.0.0.1 -p 4321 --themesDir themes -t LoveIt -D -F --navigateToChanged
Error: Error building site: failed to render pages: render of "home" failed: "C:\Projects\Website\themes\LoveIt\layouts\index.html:36:20": execute of template failed: template: index.html:36:20: executing "content" at <.Render>: error calling Render: "C:\Projects\Website\content\posts\mosquito-activity-and-weather\index.en.md:1:1": failed to execute template _default/summary.html: "C:\Projects\Website\themes\LoveIt\layouts\_default\summary.html:41:25": execute of template failed: template: _default/summary.html:41:25: executing "_default/summary.html" at <.Params.categories>: range can't iterate over Research
In addition: Warning message:
In if (is.na(c3)) vars = c(vars, HUGO_IGNOREERRORS = "error-remote-getjson") :
the condition has length > 1 and only the first element will be used

Problem deploying website to Netlify keep getting errors. I have tried multiple build commands

Github repo [https://github.com/NaveenJc10/Naveen]
Could someone please help me to solve this issue. Thank you
12:07:21 PM: Build ready to start
12:07:23 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
12:07:23 PM: build-image tag: v3.7.6
12:07:23 PM: buildbot version: cb3d235979bae64f617d34524cb2e8a9de68153f
12:07:23 PM: Fetching cached dependencies
12:07:23 PM: Failed to fetch cache, continuing with build
12:07:23 PM: Starting to prepare the repo for build
12:07:24 PM: No cached dependencies found. Cloning fresh repo
12:07:24 PM: git clone https://github.com/NaveenJc10/Naveen
12:07:25 PM: Preparing Git Reference refs/heads/main
12:07:25 PM: Parsing package.json dependencies
12:07:27 PM: Starting build script
12:07:27 PM: Installing dependencies
12:07:27 PM: Python version set to 2.7
12:07:28 PM: v12.18.0 is already installed.
12:07:29 PM: Now using node v12.18.0 (npm v6.14.4)
12:07:29 PM: Started restoring cached build plugins
12:07:29 PM: Finished restoring cached build plugins
12:07:29 PM: Attempting ruby version 2.7.1, read from environment
12:07:31 PM: Using ruby version 2.7.1
12:07:31 PM: Using PHP version 5.6
12:07:31 PM: Started restoring cached node modules
12:07:31 PM: Finished restoring cached node modules
12:07:31 PM: Installing NPM modules using NPM version 6.14.4
12:07:47 PM: > deasync#0.1.21 install /opt/build/repo/node_modules/deasync
12:07:47 PM: > node ./build.js
12:07:47 PM: linux-x64-node-12 exists; testing
12:07:47 PM: Binary is fine; exiting
12:07:47 PM: > core-js#2.6.12 postinstall /opt/build/repo/node_modules/core-js
12:07:47 PM: > node -e “try{require(’./postinstall’)}catch(e){}”
12:07:47 PM: > parcel-bundler#1.12.4 postinstall /opt/build/repo/node_modules/parcel-bundler
12:07:47 PM: > node -e “console.log(’\u001b[35m\u001b[1mLove Parcel? You can now donate to our open collective:\u001b[22m\u001b[39m\n > \u001b[34mhttps://opencollective.com/parcel/donate\u001b[0m’)”
12:07:47 PM: Love Parcel? You can now donate to our open collective:
12:07:47 PM: > Contribute to Parcel - Open Collective
12:07:48 PM: npm WARN Naveen#1.0.0 No description
12:07:48 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/fsevents):
12:07:48 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})
12:07:48 PM: added 766 packages from 461 contributors and audited 768 packages in 15.721s
12:07:48 PM: 46 packages are looking for funding
12:07:48 PM: run npm fund for details
12:07:48 PM: found 68 vulnerabilities (67 moderate, 1 high)
12:07:48 PM: run npm audit fix to fix them, or npm audit for details
12:07:48 PM: NPM modules installed
12:07:49 PM: Started restoring cached go cache
12:07:49 PM: Finished restoring cached go cache
12:07:49 PM: go version go1.14.4 linux/amd64
12:07:49 PM: go version go1.14.4 linux/amd64
12:07:49 PM: Installing missing commands
12:07:49 PM: Verify run directory
12:07:51 PM: ​
12:07:51 PM: ────────────────────────────────────────────────────────────────
12:07:51 PM: Netlify Build
12:07:51 PM: ────────────────────────────────────────────────────────────────
12:07:51 PM: ​
12:07:51 PM: ❯ Version
12:07:51 PM: #netlify/build 11.18.1
12:07:51 PM: ​
12:07:51 PM: ❯ Flags
12:07:51 PM: deployId: 60ac77f9aa712200a9963afb
12:07:51 PM: ​
12:07:51 PM: ❯ Current directory
12:07:51 PM: /opt/build/repo
12:07:51 PM: ​
12:07:51 PM: ❯ Config file
12:07:51 PM: No config file was defined: using default values.
12:07:51 PM: ​
12:07:51 PM: ❯ Context
12:07:51 PM: production
12:07:51 PM: ​
12:07:51 PM: ────────────────────────────────────────────────────────────────
12:07:51 PM: 1. Build command from Netlify app
12:07:51 PM: ────────────────────────────────────────────────────────────────
12:07:51 PM: ​
12:07:51 PM: $ parcel build --no-minify index.html
12:07:53 PM: :rotating_light: /opt/build/repo/images/logo.svg: Invalid Version: undefined
12:07:53 PM: at new SemVer (/opt/build/repo/node_modules/#babel/preset-env/node_modules/semver/semver.js:314:11)
12:07:53 PM: at compare (/opt/build/repo/node_modules/#babel/preset-env/node_modules/semver/semver.js:647:10)
12:07:53 PM: at lt (/opt/build/repo/node_modules/#babel/preset-env/node_modules/semver/semver.js:688:10)
12:07:53 PM: at /opt/build/repo/node_modules/#babel/preset-env/lib/index.js:274:22
12:07:53 PM: at Object.default (/opt/build/repo/node_modules/#babel/helper-plugin-utils/lib/index.js:22:12)
12:07:53 PM: at getEnvPlugins (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/env.js:62:34)
12:07:53 PM: at getEnvConfig (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/env.js:12:25)
12:07:53 PM: at async getBabelConfig (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/config.js:32:19)
12:07:53 PM: at async babelTransform (/opt/build/repo/node_modules/parcel-bundler/src/transforms/babel/transform.js:6:16)
12:07:53 PM: at async JSAsset.pretransform (/opt/build/repo/node_modules/parcel-bundler/src/assets/JSAsset.js:83:5)
12:07:54 PM: ​
12:07:54 PM: ────────────────────────────────────────────────────────────────
12:07:54 PM: “build.command” failed
12:07:54 PM: ────────────────────────────────────────────────────────────────
12:07:54 PM: ​
12:07:54 PM: Error message
12:07:54 PM: Command failed with exit code 1: parcel build --no-minify index.html
12:07:54 PM: ​
12:07:54 PM: Error location
12:07:54 PM: In Build command from Netlify app:
12:07:54 PM: parcel build --no-minify index.html
12:07:54 PM: ​
12:07:54 PM: Resolved config
12:07:54 PM: build:
12:07:54 PM: command: parcel build --no-minify index.html
12:07:54 PM: commandOrigin: ui
12:07:54 PM: publish: /opt/build/repo/dist
12:07:54 PM: functions:
12:07:54 PM: ‘*’: {}
12:07:54 PM: Caching artifacts
12:07:54 PM: Started saving node modules
12:07:54 PM: Finished saving node modules
12:07:54 PM: Started saving build plugins
12:07:54 PM: Finished saving build plugins
12:07:54 PM: Started saving pip cache
12:07:54 PM: Finished saving pip cache
12:07:54 PM: Started saving emacs cask dependencies
12:07:54 PM: Finished saving emacs cask dependencies
12:07:54 PM: Started saving maven dependencies
12:07:54 PM: Finished saving maven dependencies
12:07:54 PM: Started saving boot dependencies
12:07:54 PM: Finished saving boot dependencies
12:07:54 PM: Started saving rust rustup cache
12:07:54 PM: Finished saving rust rustup cache
12:07:54 PM: Started saving go dependencies
12:07:54 PM: Finished saving go dependencies
12:07:57 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
12:07:57 PM: Creating deploy upload records
12:07:57 PM: Failing build: Failed to build site
12:07:57 PM: Failed during stage ‘building site’: Build script returned non-zero exit code: 2
12:07:57 PM: Finished processing build request in 33.980133128s
Your html file should be index.html. The second reason, if your app is builded with react you should create also built file

Netlify Deployment failed with React

My Netlify Deployment is failed due to build issue :
I m trying to deploy this site directly from my Github repository.
Here is the complete log :
4:03:47 PM: Build ready to start
4:03:49 PM: build-image version: 0582042f4fc261adc7bd8333f34884959c577302
4:03:49 PM: build-image tag: v3.7.6
4:03:49 PM: buildbot version: 96f6c6faf398b8f2b7e39c2c3c6a03ac4592e535
4:03:49 PM: Fetching cached dependencies
4:03:49 PM: Failed to fetch cache, continuing with build
4:03:49 PM: Starting to prepare the repo for build
4:03:50 PM: No cached dependencies found. Cloning fresh repo
4:03:50 PM: git clone https://github.com/Ashumaurya/sorting
4:03:50 PM: Preparing Git Reference refs/heads/master
4:03:51 PM: Parsing package.json dependencies
4:03:52 PM: Starting build script
4:03:52 PM: Installing dependencies
4:03:52 PM: Python version set to 2.7
4:03:53 PM: Downloading and installing node v10.11.0...
4:03:53 PM: Downloading https://nodejs.org/dist/v10.11.0/node-v10.11.0-linux-x64.tar.xz...
4:03:54 PM: Computing checksum with sha256sum
4:03:54 PM: Checksums matched!
4:03:56 PM: Now using node v10.11.0 (npm v6.4.1)
4:03:56 PM: Started restoring cached build plugins
4:03:56 PM: Finished restoring cached build plugins
4:03:56 PM: Attempting ruby version 2.7.1, read from environment
4:03:57 PM: Using ruby version 2.7.1
4:03:57 PM: Using PHP version 5.6
4:03:57 PM: Started restoring cached node modules
4:03:57 PM: Finished restoring cached node modules
4:03:58 PM: Installing NPM modules using NPM version 6.4.1
4:04:24 PM: > core-js#2.6.12 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > core-js#3.8.2 postinstall /opt/build/repo/node_modules/core-js
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > core-js-pure#3.8.2 postinstall /opt/build/repo/node_modules/core-js-pure
4:04:25 PM: > node -e "try{require('./postinstall')}catch(e){}"
4:04:25 PM: > ejs#2.7.4 postinstall /opt/build/repo/node_modules/ejs
4:04:25 PM: > node ./postinstall.js
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.3.1 (node_modules/fsevents):
4:04:27 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.3.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
4:04:27 PM: added 1979 packages from 762 contributors and audited 1982 packages in 28.912s
4:04:27 PM: found 1269 vulnerabilities (170 moderate, 1099 high)
4:04:27 PM: run `npm audit fix` to fix them, or `npm audit` for details
4:04:27 PM: NPM modules installed
4:04:27 PM: Started restoring cached go cache
4:04:27 PM: Finished restoring cached go cache
4:04:27 PM: go version go1.14.4 linux/amd64
4:04:27 PM: go version go1.14.4 linux/amd64
4:04:27 PM: Installing missing commands
4:04:27 PM: Verify run directory
4:04:29 PM: ​
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: Netlify Build
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: ​
4:04:29 PM: ❯ Version
4:04:29 PM: #netlify/build 11.18.0
4:04:29 PM: ​
4:04:29 PM: ❯ Flags
4:04:29 PM: deployId: 60aa2f8b1d35c500072a653d
4:04:29 PM: ​
4:04:29 PM: ❯ Current directory
4:04:29 PM: /opt/build/repo
4:04:29 PM: ​
4:04:29 PM: ❯ Config file
4:04:29 PM: /opt/build/repo/netlify.toml
4:04:29 PM: ​
4:04:29 PM: ❯ Context
4:04:29 PM: production
4:04:29 PM: ​
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: 1. Build command from Netlify app
4:04:29 PM: ────────────────────────────────────────────────────────────────
4:04:29 PM: ​
4:04:29 PM: $ npm run build
4:04:29 PM: > sorting#0.1.0 build /opt/build/repo
4:04:29 PM: > react-scripts build
4:04:31 PM: Creating an optimized production build...
4:04:42 PM: Failed to compile.
4:04:42 PM:
4:04:42 PM: createRequire is not a function
4:04:42 PM: Referenced from: BaseConfig
4:04:42 PM: npm ERR! code ELIFECYCLE
4:04:42 PM: npm ERR! errno 1
4:04:42 PM: npm ERR! sorting#0.1.0 build: `react-scripts build`
4:04:42 PM: npm ERR! Exit status 1
4:04:42 PM: npm ERR!
4:04:42 PM: npm ERR! Failed at the sorting#0.1.0 build script.
4:04:42 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
4:04:42 PM: npm ERR! A complete log of this run can be found in:
4:04:42 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-05-23T10_34_42_160Z-debug.log
4:04:42 PM: ​
4:04:42 PM: ────────────────────────────────────────────────────────────────
4:04:42 PM: "build.command" failed
4:04:42 PM: ────────────────────────────────────────────────────────────────
4:04:42 PM: ​
4:04:42 PM: Error message
4:04:42 PM: Command failed with exit code 1: npm run build
4:04:42 PM: ​
4:04:42 PM: Error location
4:04:42 PM: In Build command from Netlify app:
4:04:42 PM: npm run build
4:04:42 PM: ​
4:04:42 PM: Resolved config
4:04:42 PM: build:
4:04:42 PM: command: npm run build
4:04:42 PM: commandOrigin: ui
4:04:42 PM: environment:
4:04:42 PM: - NODE_VERSION
4:04:42 PM: - YARN_VERSION
4:04:42 PM: - NPM_VERSION
4:04:42 PM: publish: /opt/build/repo/build
4:04:42 PM: Caching artifacts
4:04:42 PM: Started saving node modules
4:04:42 PM: Finished saving node modules
4:04:42 PM: Started saving build plugins
4:04:42 PM: Finished saving build plugins
4:04:42 PM: Started saving pip cache
4:04:42 PM: Finished saving pip cache
4:04:42 PM: Started saving emacs cask dependencies
4:04:42 PM: Finished saving emacs cask dependencies
4:04:42 PM: Started saving maven dependencies
4:04:42 PM: Finished saving maven dependencies
4:04:42 PM: Started saving boot dependencies
4:04:42 PM: Finished saving boot dependencies
4:04:42 PM: Started saving rust rustup cache
4:04:42 PM: Finished saving rust rustup cache
4:04:42 PM: Started saving go dependencies
4:04:42 PM: Finished saving go dependencies
4:04:45 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
4:04:45 PM: Creating deploy upload records
4:04:46 PM: Failing build: Failed to build site
4:04:46 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2
4:04:46 PM: Finished processing build request in 56.362135788s
and here is My Package.json :
{
"name": "sorting",
"version": "0.1.0",
"private": true,
"dependencies": {
"#babel/core": "^7.14.3",
"#testing-library/jest-dom": "^5.11.8",
"#testing-library/react": "^11.2.3",
"#testing-library/user-event": "^12.6.0",
"babel-eslint": "^10.1.0",
"emailjs-com": "^2.6.4",
"eslint-config-react-app": "^6.0.0",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-router-dom": "^5.2.0",
"react-scripts": "4.0.1",
"typescript": "^4.2.4",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I tried couple of things but it didn't worked. It would be really helpful if someone can explain me what is the error and how to solve it.
Thankyou
Seems like the node version v10.11.0 is the issue.
All you have to do is,
Either set a NODE_VERSION environment variable higher than 10.12.0
or
Add a .node-version or .nvmrc file to the site’s base directory in your repository and specify a higher version.
Configure Builds (Netlify): https://docs.netlify.com/configure-builds/manage-dependencies/#node-js-and-javascript
or
Use a netlify.toml file and specify as shown below.
[build.environment]
NODE_VERSION = "14.17.0"
References: https://medium.com/#PhilipAndrews/error-eslint-typeerror-createrequire-is-not-a-function-15890e9942f7

How to deploy gatsby site on netlify, if it is nested into a folder inside the repo?

I have to deploy a gatsby site on netlify for my university. I have a repo on gitlab with two subfolders, both being seperate gatsby projects. The deployment fails, I think because it tries to deploy the master folder, which is not a gatsby project. I inserted "npm run build" for the Build command and "gatsbyjs-starter-tailwindplay/public" into the Publish directory. Is that the correct way to tell netlify that it should deploy the gatsbyjs-starter-tailwindplay folder, with gatsbyjs-starter-tailwindplay being one of the repos subfolders?
I get the following Deploy log:
10:52:27 PM: Build ready to start
10:52:29 PM: build-image version: 9e0f207a27642d0115b1ca97cd5e8cebbe492f63
10:52:29 PM: build-image tag: v3.3.2
10:52:29 PM: buildbot version: 16db6527b4cafa2553c3f3f11aa8d1b46a72ff40
10:52:30 PM: Fetching cached dependencies
10:52:30 PM: Failed to fetch cache, continuing with build
10:52:30 PM: Starting to prepare the repo for build
10:52:31 PM: No cached dependencies found. Cloning fresh repo
10:52:31 PM: git clone git#gitlab.com:[deleted by me!]
10:52:32 PM: Preparing Git Reference refs/heads/master
10:52:32 PM: Found netlify.toml. Overriding site configuration
10:52:32 PM: Starting build script
10:52:32 PM: Installing dependencies
10:52:34 PM: Downloading and installing node v10.16.3...
10:52:34 PM: Downloading https://nodejs.org/dist/v10.16.3/node-v10.16.3-linux-x64.tar.xz...
10:52:34 PM:
#####
10:52:34 PM: 7.6%
10:52:34 PM:
#########################################
10:52:34 PM: ######################## 90.4%
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: #
10:52:34 PM: ########################
10:52:34 PM: ############ 100.0%
10:52:34 PM: Computing checksum with sha256sum
10:52:35 PM: Checksums matched!
10:52:37 PM: Now using node v10.16.3 (npm v6.9.0)
10:52:37 PM: Attempting ruby version 2.6.2, read from environment
10:52:39 PM: Using ruby version 2.6.2
10:52:39 PM: Using PHP version 5.6
10:52:39 PM: Started restoring cached node modules
10:52:39 PM: Finished restoring cached node modules
10:52:39 PM: Installing NPM modules using NPM version 6.9.0
10:53:08 PM: > sharp#0.22.1 install /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/sharp
10:53:08 PM: > (node install/libvips && node install/dll-copy && prebuild-install) || (node-gyp rebuild && node install/dll-copy)
10:53:09 PM: info
10:53:09 PM: sharp
10:53:09 PM: Downloading https://github.com/lovell/sharp-libvips/releases/download/v8.7.4/libvips-8.7.4-linux-x64.tar.gz
10:53:11 PM: > core-js#2.6.9 postinstall /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/core-js
10:53:11 PM: > node scripts/postinstall || echo "ignore"
10:53:11 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:53:11 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
10:53:11 PM: > https://opencollective.com/core-js
10:53:11 PM: > https://www.patreon.com/zloirock
10:53:11 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:53:11 PM: > core-js-pure#3.1.4 postinstall /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/core-js-pure
10:53:11 PM: > node scripts/postinstall || echo "ignore"
10:53:11 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:53:11 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon:
10:53:11 PM: > https://opencollective.com/core-js
10:53:11 PM: > https://www.patreon.com/zloirock
10:53:11 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:53:12 PM: > gatsby-telemetry#1.1.0 postinstall /opt/build/repo/gatsbyjs-starter-tailwindplay/node_modules/gatsby-telemetry
10:53:12 PM: > node src/postinstall.js
10:53:14 PM: npm
10:53:14 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.9 (node_modules/fsevents):
10:53:14 PM: npm
10:53:14 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.9: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:53:14 PM: added 1591 packages from 877 contributors and audited 21387 packages in 33.175s
10:53:14 PM: found 529 vulnerabilities (527 high, 2 critical)
10:53:14 PM: run `npm audit fix` to fix them, or `npm audit` for details
10:53:14 PM: NPM modules installed
10:53:14 PM: Started restoring cached go cache
10:53:14 PM: Finished restoring cached go cache
10:53:14 PM: unset GOOS;
10:53:14 PM: unset GOARCH;
10:53:14 PM: export GOROOT='/opt/buildhome/.gimme/versions/go1.12.linux.amd64';
10:53:14 PM: export PATH="/opt/buildhome/.gimme/versions/go1.12.linux.amd64/bin:${PATH}";
10:53:14 PM: go version >&2;
10:53:14 PM: export GIMME_ENV='/opt/buildhome/.gimme/env/go1.12.linux.amd64.env';
10:53:14 PM: go version go1.12 linux/amd64
10:53:14 PM: Installing missing commands
10:53:14 PM: Verify run directory
10:53:14 PM: Executing user command: npm run build
10:53:14 PM: > #oddstronaut/gatsby-starter-tailwind#3.0.25 build /opt/build/repo/gatsbyjs-starter-tailwindplay
10:53:14 PM: > yarn run clean && gatsby build
10:53:14 PM: sh: 1: yarn: not found
10:53:14 PM: npm
10:53:14 PM: ERR! file sh
10:53:14 PM: npm ERR! code ELIFECYCLE
10:53:14 PM: npm ERR! errno
10:53:14 PM: ENOENT
10:53:14 PM: npm ERR! syscall spawn
10:53:14 PM: npm
10:53:14 PM: ERR! #oddstronaut/gatsby-starter-tailwind#3.0.25 build: `yarn run clean && gatsby build`
10:53:14 PM: npm ERR! spawn ENOENT
10:53:14 PM: npm ERR!
10:53:14 PM: npm ERR! Failed at the #oddstronaut/gatsby-starter-tailwind#3.0.25 build script.
10:53:14 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:53:14 PM: npm
10:53:14 PM: ERR! A complete log of this run can be found in:
10:53:14 PM: npm ERR!
10:53:14 PM: /opt/buildhome/.npm/_logs/2019-10-03T20_53_14_985Z-debug.log
10:53:14 PM: Skipping functions preparation step: no functions directory set
10:53:14 PM: Caching artifacts
10:53:14 PM: Started saving node modules
10:53:15 PM: Finished saving node modules
10:53:15 PM: Started saving pip cache
10:53:15 PM: Finished saving pip cache
10:53:15 PM: Started saving emacs cask dependencies
10:53:15 PM: Finished saving emacs cask dependencies
10:53:15 PM: Started saving maven dependencies
10:53:15 PM: Finished saving maven dependencies
10:53:15 PM: Started saving boot dependencies
10:53:15 PM: Finished saving boot dependencies
10:53:15 PM: Started saving go dependencies
10:53:15 PM: Finished saving go dependencies
10:53:17 PM: Error running command: Build script returned non-zero exit code: 1
10:53:17 PM: Failing build: Failed to build site
10:53:17 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
10:53:18 PM: Finished processing build request in 48.202499427s
However if I go into the gatsbyjs-starter-tailwindplay folder there is no public folder, but it is definitely there in my cloned repo on my PC! Not being super experienced with git, is that supposed to be. It is the same for a repo with just the default gatsby starter page, which i can deploy just fine, so i think its supposed to be that way?!
What happens if you add a netlify.toml file in your repository root?
# Settings in the [build] context are global and are applied to all contexts
# unless otherwise overridden by more specific contexts.
[build]
# Directory to change to before starting a build.
# This is where we will look for package.json/.nvmrc/etc.
base = "gatsbyjs-starter-tailwindplay/"
# Directory (relative to root of your repo) that contains the deploy-ready
# HTML files and assets generated by the build. If a base directory has
# been specified, include it in the publish directory path.
publish = "gatsbyjs-starter-tailwindplay/public/"
# Default build command.
command = "npm run build"
The public and .cache folders are created as a result of gatsby's build process. They are set to be ignored by git in the .gitignore file.

Resources