Code builds without any errors or warnings in my local machine and runs with no problems at all. This is my first webpage, and I just cannot get it to deploy. I have been stuck in this step for a few days now and I am getting so tired looking at it. If anyone has an idea of that is going on I would really appreciate it. I am running MAC OS and VS CODE
2:10:21 PM:
2:10:21 PM: $ yarn build
2:10:22 PM: yarn run v1.22.19
2:10:22 PM: $ next build
2:10:22 PM: warn - No build cache found. Please configure build caching for faster rebuilds. Read more: https://nextjs.org/docs/messages/no-cache
2:10:22 PM: info - Linting and checking validity of types...
2:10:24 PM: info - Creating an optimized production build...
2:10:26 PM: Failed to compile.
2:10:26 PM:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/hhh.png' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img100.png' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img9.jpg' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img15.png' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: Module not found: Can't resolve '/Users/santiagoramirez/landing_githubpages/public/img11.webp' in '/opt/build/repo/pages/components'
2:10:26 PM: Import trace for requested module:
2:10:26 PM: ./pages/components/Instagram.jsx
2:10:26 PM: > Build failed because of webpack errors
2:10:26 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
2:10:26 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
2:10:26 PM:
2:10:26 PM: ────────────────────────────────────────────────────────────────
2:10:26 PM: "build.command" failed
2:10:26 PM: ────────────────────────────────────────────────────────────────
2:10:26 PM:
2:10:26 PM: Error message
2:10:26 PM: Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
2:10:26 PM:
2:10:26 PM: Error location
2:10:26 PM: In Build command from Netlify app:
2:10:26 PM: yarn build
2:10:26 PM:
2:10:26 PM: Resolved config
2:10:26 PM: build:
2:10:26 PM: command: yarn build
2:10:26 PM: commandOrigin: ui
2:10:26 PM: environment:
2:10:26 PM: - NEXT_PRIVATE_TARGET
2:10:26 PM: publish: /opt/build/repo/.next
2:10:26 PM: publishOrigin: ui
2:10:26 PM: plugins:
2:10:26 PM: - inputs: {}
2:10:26 PM: origin: ui
2:10:26 PM: package: '#netlify/plugin-nextjs'
2:10:27 PM: Caching artifacts
2:10:27 PM: Started saving node modules
2:10:27 PM: Finished saving node modules
2:10:27 PM: Started saving build plugins
2:10:27 PM: Finished saving build plugins
2:10:27 PM: Started saving yarn cache
2:10:29 PM: Finished saving yarn cache
2:10:29 PM: Started saving pip cache
2:10:29 PM: Finished saving pip cache
2:10:29 PM: Started saving emacs cask dependencies
2:10:29 PM: Finished saving emacs cask dependencies
2:10:29 PM: Started saving maven dependencies
2:10:29 PM: Finished saving maven dependencies
2:10:29 PM: Started saving boot dependencies
2:10:29 PM: Finished saving boot dependencies
2:10:29 PM: Started saving rust rustup cache
2:10:29 PM: Finished saving rust rustup cache
2:10:29 PM: Started saving go dependencies
2:10:29 PM: Finished saving go dependencies
2:10:31 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
2:10:31 PM: Creating deploy upload records
2:10:31 PM: Failing build: Failed to build site
2:10:31 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
2:10:31 PM: Finished processing build request in 38.844689685s
Related
Below is the message I got.
I have tried other solutions such as changing the deployed setting 'CI=npm build run' and set a new environmental variable CI false But none of them worked.
below is the version without setting the 'CI=npm build run' but set CI to false.
$ npm run build
1:51:55 PM: > anqi-portfolio#0.1.0 build
1:51:55 PM: > react-scripts build
1:51:56 PM: Creating an optimized production build...
1:51:56 PM: Failed to compile.
1:51:56 PM:
1:51:56 PM: Module not found: Error: Can't resolve '../src/pages/AboutPage' in '/opt/build/repo/src'
1:51:56 PM:
1:51:56 PM: "build.command" failed
1:51:56 PM: ────────────────────────────────────────────────────────────────
1:51:56 PM:
1:51:56 PM: Error message
1:51:56 PM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
1:51:56 PM:
1:51:56 PM: Error location
1:51:56 PM: In Build command from Netlify app:
1:51:56 PM: npm run build
1:51:56 PM:
1:51:56 PM: Resolved config
1:51:56 PM: build:
1:51:56 PM: command: npm run build
1:51:56 PM: commandOrigin: ui
1:51:56 PM: environment:
1:51:56 PM: - CI
1:51:56 PM: publish: /opt/build/repo/build
1:51:56 PM: publishOrigin: ui
1:51:57 PM: Caching artifacts
1:51:57 PM: Started saving node modules
1:51:57 PM: Finished saving node modules
1:51:57 PM: Started saving build plugins
1:51:57 PM: Finished saving build plugins
1:51:57 PM: Started saving pip cache
1:51:57 PM: Finished saving pip cache
1:51:57 PM: Started saving emacs cask dependencies
1:51:57 PM: Finished saving emacs cask dependencies
1:51:57 PM: Started saving maven dependencies
1:51:58 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
1:51:57 PM: Finished saving maven dependencies
1:51:57 PM: Started saving boot dependencies
1:51:57 PM: Finished saving boot dependencies
1:51:57 PM: Started saving rust rustup cache
1:51:57 PM: Finished saving rust rustup cache
1:51:57 PM: Started saving go dependencies
1:51:57 PM: Finished saving go dependencies
1:51:58 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
1:51:58 PM: Failing build: Failed to build site
1:51:58 PM: Finished processing build request in 30.452339066s
I faced a problem that the deploying next.js website on netlify is failed after I added some webp images.
7:56:07 PM: Failed to compile.
7:56:07 PM:
7:56:07 PM: ./assets/images/categories/Charitytoken.webp
7:56:07 PM: Error: Buffer has an unsupported format
7:56:07 PM: > Build error occurred
7:56:07 PM: Error: > Build failed because of webpack errors
7:56:07 PM: at /opt/build/repo/node_modules/next/dist/build/index.js:397:19
7:56:07 PM: at async Span.traceAsyncFn (/opt/build/repo/node_modules/next/dist/telemetry/trace/trace.js:60:20)
7:56:07 PM: at async Object.build [as default] (/opt/build/repo/node_modules/next/dist/build/index.js:77:25)
7:56:07 PM: error Command failed with exit code 1. (https://ntl.fyi/exit-code-1)
7:56:07 PM: info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
7:56:07 PM:
7:56:07 PM: ────────────────────────────────────────────────────────────────
7:56:07 PM: "build.command" failed
7:56:07 PM: ────────────────────────────────────────────────────────────────
7:56:07 PM:
7:56:07 PM: Error message
7:56:07 PM: Command failed with exit code 1: yarn build (https://ntl.fyi/exit-code-1)
7:56:07 PM:
7:56:07 PM: Error location
7:56:07 PM: In Build command from Netlify app:
7:56:07 PM: yarn build
7:56:07 PM:
7:56:07 PM: Resolved config
7:56:07 PM: build:
7:56:07 PM: command: yarn build
7:56:07 PM: commandOrigin: ui
7:56:07 PM: environment:
7:56:07 PM: - NEXT_PRIVATE_TARGET
7:56:07 PM: publish: /opt/build/repo/.next
7:56:07 PM: publishOrigin: ui
7:56:07 PM: plugins:
7:56:07 PM: - inputs: {}
7:56:07 PM: origin: ui
7:56:07 PM: package: '#netlify/plugin-nextjs'
7:56:07 PM: Caching artifacts
7:56:07 PM: Started saving node modules
7:56:07 PM: Finished saving node modules
7:56:07 PM: Started saving build plugins
7:56:07 PM: Finished saving build plugins
For avoiding such error, is there any way to handle webp images while deploying on netlify?
I was trying to deploy gatsby site to Netlify. I commit all files from public directory within gatsby project to my github repository and then deploy that repository on netlify, but I got an error.
After pushing to github all files and directories except for public and then deploy I got following error:
12:23:37 PM:
12:23:37 PM: ┌─────────────────────────────┐
12:23:37 PM: │ Netlify Build │
12:23:37 PM: └─────────────────────────────┘
12:23:37 PM:
12:23:37 PM: ❯ Version
12:23:37 PM: #netlify/build 3.3.0
12:23:37 PM:
12:23:37 PM: ❯ Flags
12:23:37 PM: deployId: 5f4637d3e090c2ab4a26309c
12:23:37 PM: mode: buildbot
12:23:37 PM:
12:23:37 PM: ❯ Current directory
12:23:37 PM: /opt/build/repo
12:23:37 PM:
12:23:37 PM: ❯ Config file
12:23:37 PM: No config file was defined: using default values.
12:23:37 PM:
12:23:37 PM: ❯ Context
12:23:37 PM: production
12:23:37 PM:
12:23:37 PM: ┌───────────────────────────────────┐
12:23:37 PM: │ 1. Build command from Netlify app │
12:23:37 PM: └───────────────────────────────────┘
12:23:37 PM:
12:23:37 PM: $ gatsby build
12:23:40 PM: success open and validate gatsby-configs - 0.022s
12:23:40 PM: success load plugins - 0.498s
12:23:40 PM: success onPreInit - 0.040s
12:23:40 PM: success delete html and css files from previous builds - 0.002s
12:23:40 PM: success initialize cache - 0.006s
12:23:41 PM: success copy gatsby files - 0.028s
12:23:41 PM: success onPreBootstrap - 0.005s
12:23:41 PM: success createSchemaCustomization - 0.006s
12:23:41 PM: success Checking for changed pages - 0.000s
12:23:41 PM: success source and transform nodes - 0.086s
12:23:41 PM: success building schema - 0.271s
12:23:41 PM: success createPages - 0.001s
12:23:41 PM: success Checking for changed pages - 0.000s
12:23:41 PM: success createPagesStatefully - 0.067s
12:23:41 PM: success update schema - 0.023s
12:23:41 PM: success onPreExtractQueries - 0.001s
12:23:43 PM: success extract queries from components - 2.444s
12:23:43 PM: success write out redirect data - 0.001s
12:23:43 PM: success onPostBootstrap - 0.000s
12:23:43 PM: info bootstrap finished - 6.517s
12:23:44 PM: success run static queries - 0.017s - 1/1 60.34/s
12:23:44 PM: success run page queries - 0.004s - 1/1 241.80/s
12:23:44 PM: success write out requires - 0.004s
12:24:11 PM: success Building production JavaScript and CSS bundles - 27.400s
12:24:11 PM: success Rewriting compilation hashes - 0.002s
12:24:15 PM: failed Building static HTML for pages - 3.641s
12:24:15 PM: error "document" is not available during server side rendering.
12:24:15 PM:
12:24:15 PM: > 1 | !function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t():"function"==typeof define&&define.amd?define([],t):"object"==typeof exports?exports.AOS=t():e.AOS=t()}(this,function(){return function(e){function t(o){if(n[o])return n[o].exports;var i=n[o]={exports:{},id:o,loaded:!1};return e[o].call(i.exports,i,i.exports,t),i.loaded=!0,i.exports}var n={};return t.m=e,t.c=n,t.p="dist/",t(0)}([function(e,t,n){"use strict";function o(e){return e&&e.__esModule?e:{default:e}}var i=Object.assign||function(e){for(var t=1;t<arguments.length;t++){var n=arguments[t];for(var o in n)Object.prototype.hasOwnProperty.call(n,o)&&(e[o]=n[o])}return e},r=n(1),a=(o(r),n(6)),u=o(a),c=n(7),s=o(c),f=n(8),d=o(f),l=n(9),p=o(l),m=n(10),b=o(m),v=n(11),y=o(v),g=n(14),h=o(g),w=[],k=!1,x={offset:120,delay:0,easing:"ease",duration:400,disable:!1,once:!1,startEvent:"DOMContentLoaded",throttleDelay:99,debounceDelay:50,disableMutationObserver:!1},j=function(){var e=arguments.length>0&&void
12:24:15 PM: | ^
12:24:15 PM:
12:24:15 PM: WebpackError: ReferenceError: document is not defined
12:24:15 PM:
12:24:15 PM: - aos.js:1
12:24:15 PM: node_modules/aos/dist/aos.js:1:14565
12:24:15 PM:
12:24:15 PM: - aos.js:1
12:24:15 PM: node_modules/aos/dist/aos.js:1:1506
12:24:15 PM:
12:24:15 PM: - Technologie.js:8
12:24:15 PM: src/components/Technologie.js:8:5
12:24:15 PM:
12:24:15 PM: - index.js:1
12:24:15 PM: src/pages/index.js:1:1
12:24:15 PM:
12:24:15 PM: - getLayoutRect.js:1
12:24:15 PM: node_modules/#popperjs/core/lib/dom-utils/getLayoutRect.js:1:1
12:24:15 PM:
12:24:15 PM:
12:24:15 PM:
12:24:15 PM: ┌─────────────────────────────┐
12:24:15 PM: │ "build.command" failed │
12:24:15 PM: └─────────────────────────────┘
12:24:15 PM:
12:24:15 PM: Error message
12:24:15 PM: Command failed with exit code 1: gatsby build
12:24:15 PM:
12:24:15 PM: Error location
12:24:15 PM: In Build command from Netlify app:
12:24:15 PM: gatsby build
12:24:15 PM:
12:24:15 PM: Resolved config
12:24:15 PM: build:
12:24:15 PM: command: gatsby build
12:24:15 PM: commandOrigin: ui
12:24:15 PM: publish: /opt/build/repo/public
12:24:15 PM: Caching artifacts
12:24:15 PM: Started saving node modules
12:24:15 PM: Finished saving node modules
12:24:15 PM: Started saving build plugins
12:24:15 PM: Finished saving build plugins
12:24:15 PM: Started saving pip cache
12:24:15 PM: Finished saving pip cache
12:24:15 PM: Started saving emacs cask dependencies
12:24:15 PM: Finished saving emacs cask dependencies
12:24:15 PM: Started saving maven dependencies
12:24:15 PM: Finished saving maven dependencies
12:24:15 PM: Started saving boot dependencies
12:24:15 PM: Finished saving boot dependencies
12:24:15 PM: Started saving go dependencies
12:24:15 PM: Finished saving go dependencies
12:24:18 PM: Error running command: Build script returned non-zero exit code: 1
12:24:18 PM: Failing build: Failed to build site
12:24:18 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
12:24:19 PM: Finished processing build request in 2m5.540557721s
Any suggestions? Thanks in advance.
There's a process misunderstanding there. In your repository, you should commit all files except your /public folder since it's the one that will be generated in the building and deploy process in Netlify. In addition, your netlify.toml is not adding any useful command to Netlify because they are added by default in the dashboard. As you can see in:
Note: you can find this configuration under https://app.netlify.com/sites/YOUR_PROJECT_NAME/settings/deploys
Your command is failing because you are doing the Netlify work in your repository. You are uploading a built folder (/public) that doesn't contain any package.json nor build commands so your command is unrecognized.
You must upload all files except your /public folder in your repository and let Netlify do the build process. In addition, you can improve your netlify.toml by removing the default commands.
With the new edited content it's inferred that
this build must fail locally too before pushing it to Netlify. In Gatsby, you have to check for the availability of the global objects (like window or document before using it).
It's a broad question and spreads the topic of it. If the error is in your code (you are using document object) you need to add a condition first:
If (typeof document !== 'undefined') {
//Your code here
}
If the error comes from an external source (library or dependency using window or document internally), you need to add a null loader in your webpack's configuration:
exports.onCreateWebpackConfig = ({ stage, loaders, actions }) => {
if (stage === "build-html") {
actions.setWebpackConfig({
module: {
rules: [
{
test: /bad-module/,
use: loaders.null(),
},
],
},
})
}
}
Replacing /bad-module/ for the library path in node_modules.
You can check for further details in Debugging HTML Builds Documentation
To add properly AOS package add this to your page/component:
componentDidMount() {
const AOS = require('aos');
this.aos = AOS this.aos.init()
}
componentDidUpdate() {
this.aos.refresh()
}
Or using hooks:
let AOS;
useEffect(() => {
/** * Server-side rendering does not provide the 'document' object
* therefore this import is required either in useEffect or componentDidMount as they
* are exclusively executed on a client */
const AOS = require("aos");
AOS.init({ once: true, }); }, []);
useEffect(() => { if (AOS) { AOS.refresh(); } });
I've just refactored my app by creating a folder for each component with its .js and .scss file and on local it works fine (even the npm run build command).
The problem is now it gives me an error when I try to deploy it.
It says
5:25:44 PM: ./src/Components/restaurants/RestaurantInfo/RestaurantInfo.js
5:25:44 PM: Cannot find file '../../util/Review' in './src/Components/restaurants/RestaurantInfo'.
it doesn't find it because ./src/Components/restaurants/RestaurantInfo is now just a folder and it should check ./src/Components/restaurants/RestaurantInfo/RestaurantInfo instead.
I've checked all the paths and are correct, as I said on local everything works as it should but clearly something is wrong and I can't figure it out.
Here's the its url: https://restaurant-finder-redux.netlify.app/
Github repository: https://github.com/mugg84/RestaurantFinderRedux.git
and the full error:
5:25:41 PM: Build ready to start
5:25:43 PM: build-image version: ca811f47d4c1cbd1812d1eb6ecb0c977e86d1a1d
5:25:43 PM: build-image tag: v3.3.20
5:25:43 PM: buildbot version: be8ecf2af866e16fa4301cc5c14de2ccbbb21cf4
5:25:43 PM: Fetching cached dependencies
5:25:43 PM: Starting to download cache of 254.8KB
5:25:43 PM: Finished downloading cache in 74.189736ms
5:25:43 PM: Starting to extract cache
5:25:43 PM: Failed to fetch cache, continuing with build
5:25:43 PM: Starting to prepare the repo for build
5:25:44 PM: No cached dependencies found. Cloning fresh repo
5:25:44 PM: git clone git#github.com:mugg84/RestaurantFinderRedux
5:25:45 PM: Preparing Git Reference refs/heads/master
5:25:47 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'C:\Users\Turi\Desktop\project\RestaurantsRedux\build' in the Netlify UI
5:25:47 PM: Starting build script
5:25:47 PM: Installing dependencies
5:25:47 PM: Python version set to 2.7
5:25:48 PM: v12.18.0 is already installed.
5:25:49 PM: Now using node v12.18.0 (npm v6.14.4)
5:25:49 PM: Started restoring cached build plugins
5:25:49 PM: Finished restoring cached build plugins
5:25:49 PM: Attempting ruby version 2.7.1, read from environment
5:25:51 PM: Using ruby version 2.7.1
5:25:51 PM: Using PHP version 5.6
5:25:51 PM: 5.2 is already installed.
5:25:51 PM: Using Swift version 5.2
5:25:51 PM: Started restoring cached node modules
5:25:51 PM: Finished restoring cached node modules
5:25:51 PM: Installing NPM modules using NPM version 6.14.4
5:26:28 PM: > node-sass#4.14.1 install /opt/build/repo/node_modules/node-sass
5:26:28 PM: > node scripts/install.js
5:26:29 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-72_binding.node
5:26:29 PM: Download complete
5:26:29 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
5:26:29 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-72_binding.node
5:26:30 PM: > core-js#2.6.11 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:30 PM: > core-js#3.6.5 postinstall /opt/build/repo/node_modules/core-js
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:30 PM: > core-js-pure#3.6.5 postinstall /opt/build/repo/node_modules/core-js-pure
5:26:30 PM: > node -e "try{require('./postinstall')}catch(e){}"
5:26:31 PM: > node-sass#4.14.1 postinstall /opt/build/repo/node_modules/node-sass
5:26:31 PM: > node scripts/build.js
5:26:31 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-72/binding.node
5:26:31 PM: Testing binary
5:26:31 PM: Binary is fine
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.2 (node_modules/fsevents):
5:26:33 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
5:26:33 PM: added 1778 packages from 828 contributors and audited 1782 packages in 40.593s
5:26:35 PM: 60 packages are looking for funding
5:26:35 PM: run `npm fund` for details
5:26:35 PM: found 4985 low severity vulnerabilities
5:26:35 PM: run `npm audit fix` to fix them, or `npm audit` for details
5:26:35 PM: NPM modules installed
5:26:35 PM: Started restoring cached go cache
5:26:35 PM: Finished restoring cached go cache
5:26:35 PM: go version go1.14.4 linux/amd64
5:26:35 PM: go version go1.14.4 linux/amd64
5:26:35 PM: Installing missing commands
5:26:35 PM: Verify run directory
5:26:37 PM:
5:26:37 PM: ┌─────────────────────────────┐
5:26:37 PM: │ Netlify Build │
5:26:37 PM: └─────────────────────────────┘
5:26:37 PM:
5:26:37 PM: ❯ Version
5:26:37 PM: #netlify/build 3.0.1
5:26:37 PM:
5:26:37 PM: ❯ Flags
5:26:37 PM: deployId: 5f19ba059db363022d8ef5d1
5:26:37 PM: mode: buildbot
5:26:37 PM:
5:26:37 PM: ❯ Current directory
5:26:37 PM: /opt/build/repo
5:26:37 PM:
5:26:37 PM: ❯ Config file
5:26:37 PM: /opt/build/repo/netlify.toml
5:26:37 PM:
5:26:37 PM: ❯ Context
5:26:37 PM: production
5:26:37 PM:
5:26:37 PM: ┌───────────────────────────────────┐
5:26:37 PM: │ 1. Build command from Netlify app │
5:26:37 PM: └───────────────────────────────────┘
5:26:37 PM:
5:26:37 PM: $ npm run build
5:26:37 PM: > RestaurantFinder#0.1.0 build /opt/build/repo
5:26:37 PM: > react-scripts build
5:26:38 PM: Creating an optimized production build...
5:26:44 PM: Failed to compile.
5:26:44 PM:
5:26:44 PM: ./src/Components/restaurants/RestaurantInfo/RestaurantInfo.js
5:26:44 PM: Cannot find file '../../util/Review' in './src/Components/restaurants/RestaurantInfo'.
5:26:44 PM: npm ERR! code ELIFECYCLE
5:26:44 PM: npm ERR! errno 1
5:26:44 PM: npm ERR! RestaurantFinder#0.1.0 build: `react-scripts build`
5:26:44 PM: npm ERR! Exit status 1
5:26:44 PM: npm ERR!
5:26:44 PM: npm ERR! Failed at the RestaurantFinder#0.1.0 build script.
5:26:44 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
5:26:44 PM: npm ERR! A complete log of this run can be found in:
5:26:44 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-07-23T16_26_44_363Z-debug.log
5:26:44 PM:
5:26:44 PM: If the build failed with a warning about "process.env.CI = true", this is due to "create-react-app" treating warnings as errors when in CI. In order to fix this problem, please either:
5:26:44 PM: - Fix the issues highlighted by the warnings above.
5:26:44 PM: - Or modify the "scripts.build" command in your "package.json" from "react-scripts build" to "CI= react-scripts build"
5:26:44 PM: More information can be found at https://docs.netlify.com/configure-builds/troubleshooting-tips/#build-fails-on-warning-message
5:26:44 PM:
5:26:44 PM: ┌─────────────────────────────┐
5:26:44 PM: │ "build.command" failed │
5:26:44 PM: └─────────────────────────────┘
5:26:44 PM:
5:26:44 PM: Error message
5:26:44 PM: Command failed with exit code 1: npm run build
5:26:44 PM:
5:26:44 PM: Error location
5:26:44 PM: In Build command from Netlify app:
5:26:44 PM: npm run build
5:26:44 PM:
5:26:44 PM: Resolved config
5:26:44 PM: build:
5:26:44 PM: command: npm run build
5:26:44 PM: commandOrigin: ui
5:26:44 PM: environment:
5:26:44 PM: - REACT_APP_GOOGLE_API_KEY
5:26:44 PM: - REACT_APP_MAILCHIMP_URL
5:26:44 PM: - REACT_APP_YELP_API_KEY
5:26:44 PM: publish: /opt/build/repo/build
5:26:44 PM: Caching artifacts
5:26:44 PM: Started saving node modules
5:26:44 PM: Finished saving node modules
5:26:44 PM: Started saving build plugins
5:26:44 PM: Finished saving build plugins
5:26:44 PM: Started saving pip cache
5:26:44 PM: Finished saving pip cache
5:26:44 PM: Started saving emacs cask dependencies
5:26:44 PM: Finished saving emacs cask dependencies
5:26:44 PM: Started saving maven dependencies
5:26:44 PM: Finished saving maven dependencies
5:26:44 PM: Started saving boot dependencies
5:26:44 PM: Finished saving boot dependencies
5:26:44 PM: Started saving go dependencies
5:26:44 PM: Finished saving go dependencies
5:26:47 PM: Error running command: Build script returned non-zero exit code: 1
5:26:47 PM: Failing build: Failed to build site
5:26:47 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
5:26:47 PM: Finished processing build request in 1m4.47397412s
Thanks for your help!
The issue was a discrepancy between the repository name of one folder and the local one, specifically the folder util.
In the repository it was uppercase, Util, while locally util and that was causing the issue.
That explains why locally npm run build was working bit it wasn't in deployment.
When I run the build on Netlify it fails, but when I run it on my local windows pc it runs like a charm
This is is the Netlify output (The error occurs when Netlify runs the build comand):
10:32:27 PM: Build ready to start
10:32:29 PM: build-image version: 3031d4c9e432fd7016f6279fc9ad706f9205d845
10:32:29 PM: build-image tag: v3.3.17
10:32:29 PM: buildbot version: 1f35b3abd6e2bf5230d8edf68072840fdec1513f
10:32:29 PM: Fetching cached dependencies
10:32:30 PM: Failed to fetch cache, continuing with build
10:32:30 PM: Starting to prepare the repo for build
10:32:30 PM: No cached dependencies found. Cloning fresh repo
10:32:30 PM: git clone https://github.com/ChristofferHennie/api-webapp-easyapi
10:32:31 PM: Preparing Git Reference refs/heads/master
10:32:32 PM: Different publish path detected, going to use the one specified in the Netlify configuration file: 'build' versus 'build/' in the Netlify UI
10:32:32 PM: Starting build script
10:32:32 PM: Installing dependencies
10:32:32 PM: Python version set to 2.7
10:32:34 PM: v12.18.0 is already installed.
10:32:34 PM: Now using node v12.18.0 (npm v6.14.4)
10:32:34 PM: Started restoring cached build plugins
10:32:35 PM: Finished restoring cached build plugins
10:32:35 PM: Attempting ruby version 2.7.1, read from environment
10:32:36 PM: Using ruby version 2.7.1
10:32:36 PM: Using PHP version 5.6
10:32:36 PM: 5.2 is already installed.
10:32:36 PM: Using Swift version 5.2
10:32:36 PM: Started restoring cached node modules
10:32:36 PM: Finished restoring cached node modules
10:32:37 PM: Installing NPM modules using NPM version 6.14.4
10:33:09 PM: > core-js#2.6.11 postinstall /opt/build/repo/node_modules/babel-runtime/node_modules/core-js
10:33:09 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:33:09 PM: > core-js#3.6.5 postinstall /opt/build/repo/node_modules/core-js
10:33:09 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:33:09 PM: > core-js-pure#3.6.5 postinstall /opt/build/repo/node_modules/core-js-pure
10:33:09 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:33:11 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/webpack-dev-server/node_modules/fsevents):
10:33:11 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:33:11 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
10:33:11 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:33:11 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#1.2.13 (node_modules/jest-haste-map/node_modules/fsevents):
10:33:11 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:33:11 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents#2.1.2 (node_modules/fsevents):
10:33:11 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents#2.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:33:11 PM: added 1679 packages from 795 contributors and audited 1683 packages in 33.786s
10:33:13 PM: 59 packages are looking for funding
10:33:13 PM: run `npm fund` for details
10:33:13 PM: found 1 low severity vulnerability
10:33:13 PM: run `npm audit fix` to fix them, or `npm audit` for details
10:33:13 PM: NPM modules installed
10:33:13 PM: Started restoring cached go cache
10:33:13 PM: Finished restoring cached go cache
10:33:13 PM: go version go1.14.4 linux/amd64
10:33:13 PM: go version go1.14.4 linux/amd64
10:33:13 PM: Installing missing commands
10:33:13 PM: Verify run directory
10:33:15 PM:
10:33:15 PM: ┌─────────────────────────────┐
10:33:15 PM: │ Netlify Build │
10:33:15 PM: └─────────────────────────────┘
10:33:15 PM:
10:33:15 PM: ❯ Version
10:33:15 PM: #netlify/build 2.0.10
10:33:15 PM:
10:33:15 PM: ❯ Flags
10:33:15 PM: deployId: 5ef266db8af236000856f030
10:33:15 PM: mode: buildbot
10:33:15 PM:
10:33:15 PM: ❯ Current directory
10:33:15 PM: /opt/build/repo
10:33:15 PM:
10:33:15 PM: ❯ Config file
10:33:15 PM: No config file was defined: using default values.
10:33:15 PM:
10:33:15 PM: ❯ Context
10:33:15 PM: production
10:33:15 PM:
10:33:15 PM: ┌────────────────────────────────┐
10:33:15 PM: │ 1. Build command from settings │
10:33:15 PM: └────────────────────────────────┘
10:33:15 PM:
10:33:15 PM: $ npm run build
10:33:15 PM: > api-webapi-easyapi#0.1.0 build /opt/build/repo
10:33:15 PM: > react-scripts build
10:33:16 PM: Creating an optimized production build...
10:33:19 PM: Failed to compile.
10:33:19 PM:
10:33:19 PM: ./src/App.js
10:33:19 PM: Cannot find file './components/pages/About' in './src'.
10:33:19 PM: npm ERR! code ELIFECYCLE
10:33:19 PM: npm ERR! errno 1
10:33:19 PM: npm ERR! api-webapi-easyapi#0.1.0 build: `react-scripts build`
10:33:19 PM: npm ERR! Exit status 1
10:33:19 PM: npm ERR!
10:33:19 PM: npm ERR! Failed at the api-webapi-easyapi#0.1.0 build script.
10:33:19 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
10:33:19 PM: npm ERR! A complete log of this run can be found in:
10:33:19 PM: npm ERR! /opt/buildhome/.npm/_logs/2020-06-23T20_33_19_677Z-debug.log
10:33:19 PM:
10:33:19 PM: ┌─────────────────────────────┐
10:33:19 PM: │ "build.command" failed │
10:33:19 PM: └─────────────────────────────┘
10:33:19 PM:
10:33:19 PM: Error message
10:33:19 PM: Command failed with exit code 1: npm run build
10:33:19 PM:
10:33:19 PM: Error location
10:33:19 PM: In Build command from settings:
10:33:19 PM: npm run build
10:33:19 PM:
10:33:19 PM: Resolved config
10:33:19 PM: build:
10:33:19 PM: command: npm run build
10:33:19 PM: publish: /opt/build/repo/build
10:33:19 PM: Caching artifacts
10:33:19 PM: Started saving node modules
10:33:19 PM: Finished saving node modules
10:33:19 PM: Started saving build plugins
10:33:19 PM: Finished saving build plugins
10:33:19 PM: Started saving pip cache
10:33:27 PM: Finished saving pip cache
10:33:27 PM: Started saving emacs cask dependencies
10:33:27 PM: Finished saving emacs cask dependencies
10:33:27 PM: Started saving maven dependencies
10:33:27 PM: Finished saving maven dependencies
10:33:27 PM: Started saving boot dependencies
10:33:27 PM: Finished saving boot dependencies
10:33:27 PM: Started saving go dependencies
10:33:27 PM: Finished saving go dependencies
10:33:30 PM: Error running command: Build script returned non-zero exit code: 1
10:33:30 PM: Failing build: Failed to build site
10:33:30 PM: Failed during stage 'building site': Build script returned non-zero exit code: 1
10:33:30 PM: Finished processing build request in 1m0.370032766s
It says that there is an import error in the app.js on line 4 but I can't find it. To my eyes, it is as it should be.
import React, { useState } from 'react'
import { BrowserRouter as Router, Route } from "react-router-dom"
import Header from "./components/Header"
import About from "./components/pages/About"
import GetData from "./components/GetData"
import DisplayData from "./components/DisplayData";
import Payload from "./components/Payload"
import "./App.css"
const App = () => {
const [data, setData] = useState({})
const [payload, setPayload] = useState({})
return (
<Router>
<Header/>
<Route exact path="/" render={props => (
<div className="home">
<GetData setData={setData} payload={payload}/>
<div className="main">
<Payload setPayload={setPayload} payload={payload}/>
<DisplayData data={data}/>
</div>
</div>
)}/>
<Route path="/about" component={About}/>
</Router>
)
}
export default App;
The file it points to is just a simple placeholder:
import React from 'react';
const About = () => {
return (
<div>
<h1>About</h1>
</div>
);
};
export default About;
In advance thanks for any help!
Update #1
I found the flaw. An error occurred so GitHub didn't register that the page directory changes name from "Pages" to "pages"
Just eyeballing the log it doesn't seem like there's anything wrong with the code in the file, it's complaining that it can't find the file at all. Exactly why will depend on your build setup, but my first guess is that you either haven't checked components/pages/About in or haven't pushed to your repo since checking it in.
This question suggests you can download a build or (cat a list of files from the build) to investigate that guess.
As i see, you don't have a "pages" directory inside "components" directory
10:33:19 PM: ./src/App.js
10:33:19 PM: Cannot find file './components/pages/About' in './src'.
So you have to change :
import About from "./components/pages/About"
To (depending on what you have in your repo):
import About from "./components/Pages/About"