Why am I getting an error message when I try to deploy my Gatsby website? - deployment

I have a Gatsby app.
When I build it locally, it works fine, but when I try to deploy it to Netlify or Gitlab, I get the below error message:
Netlify error message:
8:44:20 PM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
8:44:20 PM: npm WARN config location in the cache, and they are managed by
8:44:20 PM: npm WARN config [`cacache`](http://npm.im/cacache).
8:44:20 PM: npm WARN config tmp This setting is no longer used. npm stores temporary files in a special
8:44:20 PM: npm WARN config location in the cache, and they are managed by
8:44:20 PM: npm WARN config [`cacache`](http://npm.im/cacache).
8:44:23 PM: npm ERR! code ERESOLVE
8:44:23 PM: npm ERR! ERESOLVE could not resolve
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! While resolving: #mdx-js/react#1.6.22
8:44:23 PM: Creating deploy upload records
8:44:23 PM: npm ERR! Found: react#18.1.0
8:44:23 PM: npm ERR! node_modules/react
8:44:23 PM: npm ERR! react#"^18.1.0" from the root project
8:44:23 PM: npm ERR! peer react#"15.x || 16.x || 17.x || 18.x" from #gatsbyjs/reach-router#1.3.7
8:44:23 PM: npm ERR! node_modules/#gatsbyjs/reach-router
8:44:23 PM: npm ERR! #gatsbyjs/reach-router#"^1.3.6" from gatsby#4.17.1
8:44:23 PM: npm ERR! node_modules/gatsby
8:44:23 PM: npm ERR! gatsby#"^4.17.1" from the root project
8:44:24 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1 (https://ntl.fyi/exit-code-1)
8:44:23 PM: npm ERR! 13 more (babel-plugin-remove-graphql-queries, ...)
8:44:23 PM: npm ERR! peer #gatsbyjs/reach-router#"^1.3.5" from gatsby-link#4.17.0
8:44:23 PM: npm ERR! node_modules/gatsby-link
8:44:23 PM: npm ERR! gatsby-link#"^4.17.0" from gatsby#4.17.1
8:44:23 PM: npm ERR! node_modules/gatsby
8:44:23 PM: npm ERR! gatsby#"^4.17.1" from the root project
8:44:23 PM: npm ERR! 13 more (babel-plugin-remove-graphql-queries, ...)
8:44:23 PM: npm ERR! 1 more (gatsby-react-router-scroll)
8:44:23 PM: npm ERR! 9 more (gatsby, gatsby-link, gatsby-plugin-image, ...)
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! Could not resolve dependency:
8:44:23 PM: npm ERR! peer react#"^16.13.1 || ^17.0.0" from #mdx-js/react#1.6.22
8:44:23 PM: npm ERR! node_modules/#mdx-js/react
8:44:23 PM: npm ERR! #mdx-js/react#"^1.6.22" from the root project
8:44:23 PM: npm ERR! peer #mdx-js/react#"^1.0.0" from gatsby-plugin-mdx#3.17.0
8:44:23 PM: npm ERR! node_modules/gatsby-plugin-mdx
8:44:23 PM: npm ERR! gatsby-plugin-mdx#"^3.17.0" from the root project
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! Conflicting peer dependency: react#17.0.2
8:44:23 PM: npm ERR! node_modules/react
8:44:23 PM: npm ERR! peer react#"^16.13.1 || ^17.0.0" from #mdx-js/react#1.6.22
8:44:23 PM: npm ERR! node_modules/#mdx-js/react
8:44:23 PM: npm ERR! #mdx-js/react#"^1.6.22" from the root project
8:44:23 PM: npm ERR! peer #mdx-js/react#"^1.0.0" from gatsby-plugin-mdx#3.17.0
8:44:23 PM: npm ERR! node_modules/gatsby-plugin-mdx
8:44:23 PM: npm ERR! gatsby-plugin-mdx#"^3.17.0" from the root project
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! Fix the upstream dependency conflict, or retry
8:44:23 PM: npm ERR! this command with --force, or --legacy-peer-deps
8:44:23 PM: npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
8:44:23 PM: npm ERR!
8:44:23 PM: npm ERR! See /opt/buildhome/.npm/eresolve-report.txt for a full report.
8:44:23 PM: npm ERR! A complete log of this run can be found in:
8:44:23 PM: npm ERR! /opt/buildhome/.npm/_logs/2022-06-25T17_44_20_693Z-debug-0.log
8:44:23 PM: Error during NPM install
8:44:23 PM: Build was terminated: Build script returned non-zero exit code: 1
8:44:23 PM: Failing build: Failed to build site
8:44:24 PM: Finished processing build request in 11.866525747s
Gitlab erro message:
$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: #mdx-js/react#1.6.22
npm ERR! Found: react#18.1.0
npm ERR! node_modules/react
npm ERR! react#"^18.1.0" from the root project
npm ERR! peer react#"15.x || 16.x || 17.x || 18.x" from #gatsbyjs/reach-router#1.3.7
npm ERR! node_modules/#gatsbyjs/reach-router
npm ERR! #gatsbyjs/reach-router#"^1.3.6" from gatsby#4.17.1
npm ERR! node_modules/gatsby
npm ERR! gatsby#"^4.17.1" from the root project
npm ERR! 13 more (babel-plugin-remove-graphql-queries, ...)
npm ERR! peer #gatsbyjs/reach-router#"^1.3.5" from gatsby-link#4.17.0
npm ERR! node_modules/gatsby-link
npm ERR! gatsby-link#"^4.17.0" from gatsby#4.17.1
npm ERR! node_modules/gatsby
npm ERR! gatsby#"^4.17.1" from the root project
npm ERR! 13 more (babel-plugin-remove-graphql-queries, ...)
npm ERR! 1 more (gatsby-react-router-scroll)
npm ERR! 9 more (gatsby, gatsby-link, gatsby-plugin-image, ...)
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! peer react#"^16.13.1 || ^17.0.0" from #mdx-js/react#1.6.22
npm ERR! node_modules/#mdx-js/react
npm ERR! #mdx-js/react#"^1.6.22" from the root project
npm ERR! peer #mdx-js/react#"^1.0.0" from gatsby-plugin-mdx#3.17.0
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! gatsby-plugin-mdx#"^3.17.0" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#17.0.2
npm ERR! node_modules/react
npm ERR! peer react#"^16.13.1 || ^17.0.0" from #mdx-js/react#1.6.22
npm ERR! node_modules/#mdx-js/react
npm ERR! #mdx-js/react#"^1.6.22" from the root project
npm ERR! peer #mdx-js/react#"^1.0.0" from gatsby-plugin-mdx#3.17.0
npm ERR! node_modules/gatsby-plugin-mdx
npm ERR! gatsby-plugin-mdx#"^3.17.0" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /root/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2022-06-25T18_16_56_033Z-debug-0.log
Cleaning up project directory and file based variables 00:01
ERROR: Job failed: exit code 1
I have deployed gatsby sites before and have not done anything differently this time. And the site is just a simple page with some CSS.
What could be the reason for there errors?

The error is a peer dependency conflict relating to versions of react, which provides guidance on how you can attempt to resolve it:
npm ERR! Fix the upstream dependency conflict, or retry npm ERR! this
command with --force, or --legacy-peer-deps npm ERR! to accept an
incorrect (and potentially broken) dependency resolution.
To do this on Netlify you can use the NPM_FLAGS environment variable.

Related

Error in github action while installing npm dependencies

I am trying to setup actions for NextJS app using the following yml file
name: Frontend Build
on: push
jobs:
build:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout#v3
- uses: actions/setup-node#v3
with:
node-version: "18"
- run: |
cd frontend
npm ci
npm run build
but i get the error every time npm ci or npm install is run
It says :
Run cd frontend
npm ERR! code E401
npm ERR! Incorrect or missing password.
npm ERR! If you were trying to login, change your password, create an
npm ERR! authentication token or enable two-factor authentication then
npm ERR! that means you likely typed your password in incorrectly.
npm ERR! Please try again, or recover your password at:
npm ERR! https://www.npmjs.com/forgot
npm ERR!
npm ERR! If you were doing some other operation then your saved credentials are
npm ERR! probably out of date. To correct this please try logging in again with:
npm ERR! npm login
npm ERR! A complete log of this run can be found in:
npm ERR! /home/runner/.npm/_logs/2023-02-18T16_14_12_437Z-debug-0.log
Error: Process completed with exit code 1.
i did not see anyone setting password for public npm registry.
Thanks in advance
You have to create an .npmrc file with proper authToken when installing a secured dependencies.
name: "Create .npmrc"
run: |
echo "registry.npmjs.org/:_authToken=${NPM_TOKEN}" >> .npmrc
Then you can call npm install.

GitHub action fails on npm ci

I have git action to run prettier(Code formatter). Below is the format.yml file of git action.
name: Format code with prettier
on:
push:
branches-ignore:
- master
jobs:
format:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout#v2
# Install NPM dependencies, cache them correctly
- name: Run prettier
run: |
npm ci
npm run prettier-check
The error that I am getting is listed below.
npm WARN old lockfile
npm WARN old lockfile The package-lock.json file was created with an old version of npm,
npm WARN old lockfile so supplemental metadata must be fetched from the registry.
npm WARN old lockfile
npm WARN old lockfile This is a one-time fix-up, please be patient...
npm WARN old lockfile
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: 'react-lottie#1.2.3',
npm WARN EBADENGINE required: { npm: '^3.0.0' },
npm WARN EBADENGINE current: { node: 'v16.13.0', npm: '8.1.0' }
npm WARN EBADENGINE }
...
npm ERR! code 1
npm ERR! path /home/runner/work/Web/node_modules/node-sass
npm ERR! command failed
npm ERR! command sh -c node scripts/build.js
npm ERR! Building: /usr/local/bin/node /home/runner/work/Web/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
npm ERR! make: Entering directory '/home/runner/work/Web/node_modules/node-sass/build'
npm ERR! g++ '-DNODE_GYP_MODULE_NAME=libsass' '-DUSING_UV_SHARED=1' '-DUSING_V8_SHARED=1' '-DV8_DEPRECATION_WARNINGS=1' '-DV8_DEPRECATION_WARNINGS' '-DV8_IMMINENT_DEPRECATION_WARNINGS' '-D_GLIBCXX_USE_CXX11_ABI=1' '-D_LARGEFILE_SOURCE' '-D_FILE_OFFSET_BITS=64' '-D__STDC_FORMAT_MACROS' '-DOPENSSL_NO_PINSHARED' '-DOPENSSL_THREADS' '-DLIBSASS_VERSION="3.5.5"' -I/home/runner/.node-gyp/16.13.0/include/node -I/home/runner/.node-gyp/16.13.0/src -I/home/runner/.node-gyp/16.13.0/deps/openssl/config -I/home/runner/.node-gyp/16.13.0/deps/openssl/openssl/include -I/home/runner/.node-gyp/16.13.0/deps/uv/include -I/home/runner/.node-gyp/16.13.0/deps/zlib -I/home/runner/.node-gyp/16.13.0/deps/v8/include -I../src/libsass/include -fPIC -pthread -Wall -Wextra -Wno-unused-parameter -m64 -O3 -fno-omit-frame-pointer -std=gnu++14 -std=c++0x -fexceptions -frtti -MMD -MF ./Release/.deps/Release/obj.target/libsass/src/libsass/src/ast.o.d.raw -c -o Release/obj.target/libsass/src/libsass/src/ast.o ../src/libsass/src/ast.cpp
...
npm ERR! gyp verb extracted file from tarball include/node/uv/os390.h
npm ERR! gyp verb extracted file from tarball include/node/uv/posix.h
npm ERR! gyp verb extracted file from tarball include/node/uv/stdint-msvc2008.h
npm ERR! gyp verb extracted file from tarball include/node/uv/sunos.h
npm ERR! gyp verb extracted file from tarball include/node/uv/threadpool.h
npm ERR! gyp verb extracted file from tarball include/node/uv/unix.h
npm ERR! gyp verb extracted file from tarball include/node/uv/win.h
npm ERR! gyp verb extracted file from tarball include/node/uv/errno.h
npm ERR! gyp verb extracted file from tarball include/node/uv/tree.h
npm ERR!
Error: Process completed with exit code 1.
Git action yml file used to work before. I haven't changed any version/package-lock file. Still, it is failing. Can anyone suggest a solution from the error log?
It seems you are running different node version in your githubAction.
Set up the same node version that you use local(e.g. 14) before to run npm ci:
- uses: actions/setup-node#v2
with:
node-version: '14'
- name: Run prettier
run: |
npm ci
npm run prettier-check
...

Netlify Deploy Command failed with exit code 254: npm run build-studio && cp studio/netlify.toml studio/dist

Please help! I’m a newb! Trying to deploy my first site on Netlify, using Sanity’s Gatsby portfolio template. It deployed just fine the first time, then I did some edits and now it fails with “Command failed with exit code 254: npm run build-studio && cp studio/netlify.toml studio/dist”. The site has always built and run locally with no issues.
I’ve tried many things, like deleting package-lock.json &/or node_modules folder in the root as well as in the studio and web folders and running “npm install” again. Tried “npm update” in root and studio and web folders. Tried tinkering with the postinstall script in the root folder’s package.json file. Tried running “npm install --force --legacy-peer-deps”. Tried cleaning my cache in root, studio and web folders. Basically tried everything I saw in the Netlify forums and Stackoverflow forums and elsewhere when googling my issue…
Here is the github repo: https://github.com/ericerodgers/portfolio.
Here is where the deploy seems to break:
11:01:47 PM: lerna info Installing external dependencies
11:04:48 PM: lerna ERR! npm ci exited 254 in ‘sanity-gatsby-portfolio-studio’
11:04:48 PM: lerna ERR! npm ci stderr:
11:04:48 PM: npm WARN tarball tarball data for which-
module#https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz (sha1-
2e8H3Od7mQK4o6j6SzHD4/fm6Ho=) seems to be corrupted. Trying again.
Here is the error message after lines and lines of “npm WARN tarball tarball data…”:
11:04:48 PM: “build.command” failed
11:04:48 PM: ────────────────────────────────────────────────────────────────
11:04:48 PM: ​
11:04:48 PM: Error message
11:04:48 PM: Command failed with exit code 254: npm run build-studio && cp
studio/netlify.toml studio/dist
11:04:48 PM: ​
11:04:48 PM: Error location
11:04:48 PM: In Build command from Netlify app:
11:04:48 PM: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: ​
11:04:48 PM: Resolved config
11:04:48 PM: build:
11:04:48 PM: base: /opt/build/repo
11:04:48 PM: command: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: commandOrigin: ui
11:04:48 PM: environment:
11:04:48 PM: - NETLIFY_BUILD_DEBUG
11:04:48 PM: publish: /opt/build/repo/studio/dist
11:04:48 PM: publishOrigin: ui
Here is the full deploy log (minus a large chunk of the “npm WARN tarball tarball data…” lines):
11:01:25 PM: build-image version: fa439ad1ab9393b2c0d449d8d7c033927683f4b0
11:01:25 PM: build-image tag: v4.3.0
11:01:25 PM: buildbot version: bfa1ece451875e5fe124c5b0a59bb85e0abb8d50
11:01:25 PM: Fetching cached dependencies
11:01:25 PM: Starting to download cache of 147.2MB
11:01:27 PM: Finished downloading cache in 1.527898759s
11:01:27 PM: Starting to extract cache
11:01:32 PM: Finished extracting cache in 5.608708305s
11:01:32 PM: Finished fetching cache in 7.332795262s
11:01:32 PM: Starting to prepare the repo for build
11:01:33 PM: Preparing Git Reference refs/heads/main
11:01:34 PM: Parsing package.json dependencies
11:01:34 PM:
​
❯ Initial build environment
baseRelDir: true
branch: main
context: production
cwd: /opt/build/repo
featureFlags: []
mode: buildbot
repositoryRoot: /opt/build/repo
siteId: 0e615e6e-e933-48da-a5c5-0e7c3826be41
​
❯ UI build settings
baseRelDir: true
build:
base: /
command: npm run build-studio && cp studio/netlify.toml studio/dist
environment:
- NETLIFY_BUILD_DEBUG
publish: /studio/dist
​
❯ Resolved build environment
branch: main
buildDir: /opt/build/repo
context: production
env: []
​
❯ Resolved config
build:
base: /opt/build/repo
command: npm run build-studio && cp studio/netlify.toml studio/dist
commandOrigin: ui
environment:
- NETLIFY_BUILD_DEBUG
publish: /opt/build/repo/studio/dist
publishOrigin: ui
11:01:34 PM: Different build dir detected, going to use the one specified in the Netlify configuration file: '' versus '/' in the Netlify UI
11:01:34 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'studio/dist' versus '/studio/dist' in the Netlify UI
11:01:35 PM: Starting build script
11:01:35 PM: Installing dependencies
11:01:35 PM: Python version set to 2.7
11:01:35 PM: Started restoring cached node version
11:01:39 PM: Finished restoring cached node version
11:01:40 PM: v16.9.1 is already installed.
11:01:40 PM: Now using node v16.9.1 (npm v7.21.1)
11:01:41 PM: Started restoring cached build plugins
11:01:41 PM: Finished restoring cached build plugins
11:01:41 PM: Attempting ruby version 2.7.2, read from environment
11:01:43 PM: Using ruby version 2.7.2
11:01:43 PM: Using PHP version 8.0
11:01:43 PM: Started restoring cached node modules
11:01:43 PM: Finished restoring cached node modules
11:01:43 PM: Started restoring cached go cache
11:01:43 PM: Finished restoring cached go cache
11:01:44 PM: go version go1.16.5 linux/amd64
11:01:44 PM: go version go1.16.5 linux/amd64
11:01:44 PM: Installing missing commands
11:01:44 PM: Verify run directory
11:01:45 PM: ​
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM: Netlify Build
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM: ​
11:01:45 PM: ❯ Version
11:01:45 PM: #netlify/build 18.8.0
11:01:45 PM: ​
11:01:45 PM: ❯ Flags
11:01:45 PM: apiHost: api.netlify.com
11:01:45 PM: baseRelDir: true
11:01:45 PM: branch: main
11:01:45 PM: buildId: 613d6d7bf1748000085c421b
11:01:45 PM: buildbotServerSocket: /tmp/netlify-buildbot-socket
11:01:45 PM: cacheDir: /opt/build/cache
11:01:45 PM: cachedConfigPath: /tmp/netlify_config.json
11:01:45 PM: context: production
11:01:45 PM: cwd: /opt/build/repo
11:01:45 PM: deployId: 613d6d7bf1748000085c421d
11:01:45 PM: featureFlags:
11:01:45 PM: - zisiEsbuildDynamicImports
11:01:45 PM: framework: unknown
11:01:45 PM: functionsDistDir: /tmp/zisi-613d6d7bf1748000085c421d
11:01:45 PM: mode: buildbot
11:01:45 PM: nodePath: /opt/buildhome/.nvm/versions/node/v16.9.1/bin/node
11:01:45 PM: repositoryRoot: /opt/build/repo
11:01:45 PM: saveConfig: true
11:01:45 PM: sendStatus: true
11:01:45 PM: siteId: 0e615e6e-e933-48da-a5c5-0e7c3826be41
11:01:45 PM: statsd:
11:01:45 PM: host: datadog-agent
11:01:45 PM: port: 8125
11:01:45 PM: testOpts:
11:01:45 PM: silentLingeringProcesses: ''
11:01:45 PM: ​
11:01:45 PM: ❯ Current directory
11:01:45 PM: /opt/build/repo
11:01:45 PM: ​
11:01:45 PM: ❯ Config file
11:01:45 PM: No config file was defined: using default values.
11:01:45 PM: ​
11:01:45 PM: ❯ Resolved config
11:01:45 PM: build:
11:01:45 PM: base: /opt/build/repo
11:01:45 PM: command: npm run build-studio && cp studio/netlify.toml studio/dist
11:01:45 PM: commandOrigin: ui
11:01:45 PM: environment:
11:01:45 PM: - NETLIFY_BUILD_DEBUG
11:01:45 PM: publish: /opt/build/repo/studio/dist
11:01:45 PM: publishOrigin: ui
11:01:45 PM: ​
11:01:45 PM: ❯ Context
11:01:45 PM: production
11:01:45 PM: ​
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM: 1. Build command from Netlify app
11:01:45 PM: ────────────────────────────────────────────────────────────────
11:01:45 PM: ​
11:01:45 PM: $ npm run build-studio && cp studio/netlify.toml studio/dist
11:01:46 PM: > sanity-gatsby-portfolio#0.0.0 build-studio
11:01:46 PM: > lerna bootstrap && (cd studio && npm run build)
11:01:46 PM: lerna notice cli v4.0.0
11:01:46 PM: lerna info ci enabled
11:01:47 PM: lerna info Bootstrapping 2 packages
11:01:47 PM: lerna info Installing external dependencies
11:04:48 PM: lerna ERR! npm ci exited 254 in 'sanity-gatsby-portfolio-studio'
11:04:48 PM: lerna ERR! npm ci stderr:
11:04:48 PM: npm WARN tarball tarball data for which-module#https://registry.npmjs.org/which-module/-/which-module-2.0.0.tgz (sha1-2e8H3Od7mQK4o6j6SzHD4/fm6Ho=) seems to be corrupted. Trying again.
11:04:48 PM: npm WARN tarball tarball data for normalize-path#https://registry.npmjs.org/normalize-path/-/normalize-path-2.1.1.tgz (sha1-GrKLVW4Zg2Oowab35vogE3/mrtk=) seems to be corrupted. Trying again.
11:04:48 PM: npm ERR! code ENOENT
11:04:48 PM: npm ERR! syscall lstat
11:04:48 PM: npm ERR! path /opt/buildhome/.npm/_cacache/content-v2/sha1/b5/24/3d8f3ec1aa35f1364605bc0d1036e30ab69f
11:04:48 PM: npm ERR! errno -2
11:04:48 PM: npm ERR! enoent ENOENT: no such file or directory, lstat '/opt/buildhome/.npm/_cacache/content-v2/sha1/b5/24/3d8f3ec1aa35f1364605bc0d1036e30ab69f'
11:04:48 PM: npm ERR! enoent This is related to npm not being able to find a file.
11:04:48 PM: npm ERR! enoent
11:04:48 PM: npm ERR! A complete log of this run can be found in:
11:04:48 PM: npm ERR! /opt/buildhome/.npm/_logs/2021-09-12T03_04_47_826Z-debug.log
11:04:48 PM: lerna ERR! npm ci exited 254 in 'sanity-gatsby-portfolio-studio'
11:04:48 PM: ​
11:04:48 PM: ────────────────────────────────────────────────────────────────
11:04:48 PM: "build.command" failed
11:04:48 PM: ────────────────────────────────────────────────────────────────
11:04:48 PM: ​
11:04:48 PM: Error message
11:04:48 PM: Command failed with exit code 254: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: ​
11:04:48 PM: Error location
11:04:48 PM: In Build command from Netlify app:
11:04:48 PM: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: ​
11:04:48 PM: Resolved config
11:04:48 PM: build:
11:04:48 PM: base: /opt/build/repo
11:04:48 PM: command: npm run build-studio && cp studio/netlify.toml studio/dist
11:04:48 PM: commandOrigin: ui
11:04:48 PM: environment:
11:04:48 PM: - NETLIFY_BUILD_DEBUG
11:04:48 PM: publish: /opt/build/repo/studio/dist
11:04:48 PM: publishOrigin: ui
11:04:48 PM: Caching artifacts
11:04:48 PM: Started saving node modules
11:04:48 PM: Finished saving node modules
11:04:48 PM: Started saving build plugins
11:04:48 PM: Finished saving build plugins
11:04:48 PM: Started saving pip cache
11:04:48 PM: Finished saving pip cache
11:04:48 PM: Started saving emacs cask dependencies
11:04:48 PM: Finished saving emacs cask dependencies
11:04:48 PM: Started saving maven dependencies
11:04:48 PM: Finished saving maven dependencies
11:04:48 PM: Started saving boot dependencies
11:04:48 PM: Finished saving boot dependencies
11:04:48 PM: Started saving rust rustup cache
11:04:48 PM: Finished saving rust rustup cache
11:04:48 PM: Started saving go dependencies
11:04:48 PM: Finished saving go dependencies
11:04:48 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
11:04:48 PM: Failing build: Failed to build site
11:04:48 PM: Finished processing build request in 3m23.585558362s```
I got this question answered with the help of #coelmay in the netlify forums...
https://answers.netlify.com/t/netlify-deploy-command-failed-with-exit-code-254-npm-run-build-studio-cp-studio-netlify-toml-studio-dist/44017/2
I deleted the yarn.lock file, deleted "&& lerna bootstrap" from the studio build script, and edited netlify.toml file to read:
[build]
command = "CI= npm run build"
I deployed to netlify from the root portfolio folder with these changes and the sanity studio build completed, but the gatsby website failed with some error codes indicating problems with the sanity schema… In the Sanity.io UI I saw an error message asking if I wanted to delete a schema I thought I’d already successfully deleted, and I confirmed the delete. I redeployed graphql locally and redeployed the site one last time and now everything works!
I don’t really know how or why I had a yarn.lock file or why the studio build script include “lerna bootstrap”, I didn’t really do very major alterations to the sanity/gatsby portfolio template I found on sanity.io… I mainly just added new content.
Big thanks to #coelmay in the netlify forum for helping me with this. And good luck to anyone else who has a similar problem tweaking and deploying this sanity/gatsby portfolio template!

GitHub action in GitHub Enterprise giving 401 and 404s on npm packages

I am using semantic version action on my GitHub enterprise repository. It was working fine until recently, where it started failing with this error
Error: Command failed: npm ci --only=prod
npm ERR! code E401
npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-23T10_41_00_344Z-debug.log
at ChildProcess.exithandler (child_process.js:295:12)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
killed: false,
code: 1,
signal: null,
cmd: 'npm ci --only=prod',
stdout: '',
stderr: 'npm ERR! code E401\n' +
'npm ERR! Unable to authenticate, need: Basic realm="GitHub Package Registry"\n' +
'\n' +
'npm ERR! A complete log of this run can be found in:\n' +
'npm ERR! /root/.npm/_logs/2021-08-23T10_41_00_344Z-debug.log\n'
The action I use is not expected to publish anything to GitHub Package Registry, maybe only read from Package Registry. So after googling I found this on SO and elsewhere - https://stackoverflow.com/a/63243950/1182982
So I updated my action to look like this now (I added the step: Setup node, it wasn't there before)
#===============================================================================
#=========================== Semamtic Version ==========================
#===============================================================================
semver:
name: Semantic Versioning
runs-on: [self-hosted, linux, x64]
steps:
- name: Setup node
run: |
echo "//npm.pkg.github.com/:_authToken=${{ secrets.GITHUBCOM_TOKEN }}" >> ~/.npmrc
echo "#yrshaikh:registry=https://npm.pkg.github.com" >> ~/.npmrc
echo 'registry "https://registry.yarnpkg.com"' >> ~/.yarnrc
- uses: actions/checkout#v2
- name: Semantic Release
id: semantic
# https://github.com/cycjimmy/semantic-release-action
uses: internal-front-end/semantic-release-action#v2
outputs:
new_release_published: ${{ steps.semantic.outputs.new_release_published }}
new_release_version: ${{ steps.semantic.outputs.new_release_version }}
Note, the GITHUBCOM_TOKEN I created using my github.com personal profile (And gave read packages/repo access) and OWNER_NAME in #yrshaikh:registry=https://npm.pkg.github.com I have filled in github.com user id.
After doing these changes the 401 authentication error has gone.
But I see a different error, which I have not been able to resolve -
Error: Command failed: npm --loglevel error ci --only=prod
npm ERR! code E404
npm ERR! 404 Not Found - GET https://npm.pkg.github.com/#actions%2fcore - npm package "core" does not exist under owner "actions"
npm ERR! 404
npm ERR! 404 '#actions/core#1.2.7' is not in the npm registry.
npm ERR! 404 You should bug the author to publish it (or use the name yourself!)
npm ERR! 404
npm ERR! 404 Note that you can also install from a
npm ERR! 404 tarball, folder, http url, or git url.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2021-08-25T05_40_28_115Z-debug.log
at ChildProcess.exithandler (child_process.js:295:12)
at ChildProcess.emit (events.js:210:5)
at maybeClose (internal/child_process.js:1021:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:283:5) {
killed: false,
code: 1,
signal: null,
cmd: 'npm --loglevel error ci --only=prod',
stdout: '',
stderr: 'npm ERR! code E404\n' +
'npm ERR! 404 Not Found - GET https://npm.pkg.github.com/#actions%2fcore - npm package "core" does not exist under owner "actions"\n' +
'npm ERR! 404 \n' +
"npm ERR! 404 '#actions/core#1.2.7' is not in the npm registry.\n" +
'npm ERR! 404 You should bug the author to publish it (or use the name yourself!)\n' +
'npm ERR! 404 \n' +
'npm ERR! 404 Note that you can also install from a\n' +
'npm ERR! 404 tarball, folder, http url, or git url.\n' +
'\n' +
'npm ERR! A complete log of this run can be found in:\n' +
'npm ERR! /root/.npm/_logs/2021-08-25T05_40_28_115Z-debug.log\n'
}
Any help or direction will be appreciated.
There doesn't seem to be anything wrong about the ~/.npmrc:
#${OWNER}:registry=https://npm.pkg.github.com
//npm.pkg.github.com/:_authToken=${TOKEN}
Have you tried to regenerate that personal access token? Be aware that these secrets also have scopes, so they may resolve in a private repository, but not necessarily a public repository.
$GITHUB_TOKEN may not have sufficient permissions; try adding a personal access token instead.
What does npm login --scope=#yrshaikh --registry=https://npm.pkg.github.com give?

Ionic deployment build error with cypress in gitlab ci

I have a CI/CD process with gitlab ci for ionic app deployment for auto content update using this gitlab-ci.yml
image: cypress/base:10
stages:
- build
before_script:
- rm -rf node_modules
- npm install
- npm install -g tslint typescript
build_app:
stage: build
artifacts:
paths:
- /myApp/myApp-app/cypress/screenshots/
- /myApp/myApp-app/cypress/videos/
expire_in: 1 week
when: always
script:
# run tslint
- tslint --project tsconfig.json --config tslint.json
- npm run e2e
The above step is used for build. But build is getting failed with the below error.
starting server using command "ionic:serve"
and when url "http-get://localhost:8100" is responding
running tests using command "npm run cypress:run"
/bin/sh: 1: ionic:serve: not found
Error: server closed unexpectedly
at ChildProcess.onClose (/builds/myApp-ai/myApp-app/node_modules/start-server-and-test/src/index.js:68:14)
at ChildProcess.emit (events.js:182:13)
at maybeClose (internal/child_process.js:962:16)
at Process.ChildProcess._handle.onexit (internal/child_process.js:251:5)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! mapsit-app#0.0.1 e2e: `start-server-and-test ionic:serve http-get://localhost:8100 cypress:run`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the mapsit-app#0.0.1 e2e script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /root/.npm/_logs/2019-09-08T05_50_39_435Z-debug.log
Uploading artifacts...
WARNING: /myApp/myApp-app/cypress/screenshots/: no matching files
WARNING: /myApp/myApp-app/cypress/videos/: no matching files
ERROR: No files to upload
ERROR: Job failed: exit code 1