Project with sass failed to deploy on netlify - netlify

Please help. It's my first time deploying a project with sass on netlify and it always says "Deploy failed" and these appears on the deploy log:
🚨 Build failed.
8:13:06 PM: #parcel/namer-default: Target "main" declares an output file path of "index.js"
8:13:06 PM: which does not match the compiled bundle type "html".
8:13:06 PM: /opt/build/repo/package.json:5:11
8:13:06 PM: 4 | "description": "",
8:13:06 PM: > 5 | "main": "index.js",
8:13:06 PM: > | ^^^^^^^^^^ Did you mean "index.html"?
8:13:06 PM: 6 | "scripts": {
8:13:06 PM: 7 | "dev": "parcel src/index.html",
8:13:06 PM: πŸ’‘ Try changing the file extension of "main" in package.json.
8:13:06 PM: ​
8:13:06 PM: ────────────────────────────────────────────────────────────────
8:13:06 PM: "build.command" failed
8:13:06 PM: ────────────────────────────────────────────────────────────────
8:13:06 PM: ​
8:13:06 PM: Error message
8:13:06 PM: Command failed with exit code 1: npm run build
8:13:06 PM: ​
8:13:06 PM: Error location
8:13:06 PM: In Build command from Netlify app:
8:13:06 PM: npm run build
I have no idea how to fix this problem.

Related

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

Error on Netlify Build: Import assignment cannot be used when targeting ECMAScript modules

This is the what the log files are showing on netlify
────────────────────────────────────────────────────────────────
5:26:11 PM: 1. #netlify/plugin-nextjs (onPreBuild event)
5:26:11 PM: ────────────────────────────────────────────────────────────────
5:26:11 PM: ​
5:26:11 PM: No Next.js cache to restore.
5:26:11 PM: Netlify configuration property "build.environment.NEXT_PRIVATE_TARGET" value changed.
5:26:11 PM: ​
5:26:11 PM: (#netlify/plugin-nextjs onPreBuild completed in 28ms)
5:26:11 PM: ​
5:26:11 PM: ────────────────────────────────────────────────────────────────
5:26:11 PM: 2. Build command from Netlify app
5:26:11 PM: ────────────────────────────────────────────────────────────────
5:26:11 PM: ​
5:26:11 PM: $ yarn build
5:26:11 PM: yarn run v1.22.17
5:26:12 PM: $ next build
5:26:12 PM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
5:26:12 PM: info - Checking validity of types...
5:26:17 PM: Failed to compile.
5:26:17 PM:
5:26:17 PM: ./node_modules/mongoose/types/cursor.ts:1:1
5:26:17 PM: Type error: Import assignment cannot be used when targeting ECMAScript modules. Consider using 'import * as ns from "mod"', 'import {a} from "mod"', 'import d from "mod"', or another module format instead.
5:26:17 PM: > 1 | import stream = require('stream');
5:26:17 PM: | ^
5:26:17 PM: 2 |
5:26:17 PM: 3 | declare module 'mongoose' {
5:26:17 PM: 4 | type CursorFlag = 'tailable' | 'oplogReplay' | 'noCursorTimeout' | 'awaitData' | 'partial';
5:26:17 PM: error Command failed with exit code 1.
5:26:17 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
5:26:17 PM: ​
5:26:17 PM: ────────────────────────────────────────────────────────────────
5:26:17 PM: "build.command" failed
5:26:17 PM: ────────────────────────────────────────────────────────────────
5:26:17 PM: ​
Locally the build is successful. I added environment variables on netlify to ensure versions of node and yarn are the same as those local and it stil fails.
I tried the solution of replacing module on tsconfi.json from
"module": "esnext"
to
"module": "commonjs"
The only time the build on netlify works is when typescript errors are set to be ignored.
Any ideas on how to build successfully if i don't want to ignore typescript errors?
I'd try using import or require syntax here
import stream from "steam"
// Or
const stream = require ('stream')

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

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

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

Resources