Vercel Deployment Error: Command "npm run build" exited with 1
Asked Answered
U

15

17

I am developing a React app in VS Code. I used create-react-app for setup. I can run the project without any problem with npm start. When I tried to publish the project with Vercel I got errors:

Already tried deleting node_modules and npm install again.

Error! Command "npm run build" exited with 1
Error! Check your logs at https://...

You can see the logs below:

13:55:05.231    Retrieving list of deployment files...
13:55:06.975    Downloading 32 deployment files...
13:55:09.142    Analyzing source code...
13:55:11.289    Installing build runtime...
13:55:15.911    Build runtime installed: 4622.485ms
13:55:20.151    Looking up build cache...
13:55:21.237    Build cache not found
13:55:22.615    Detected package.json
13:55:22.616    Installing dependencies...
13:55:58.492    > [email protected] postinstall /vercel/path0/node_modules/babel-runtime/node_modules/core-js
13:55:58.492    > node -e "try{require('./postinstall')}catch(e){}"
13:55:58.604    > [email protected] postinstall /vercel/path0/node_modules/core-js
13:55:58.604    > node -e "try{require('./postinstall')}catch(e){}"
13:55:58.683    > [email protected] postinstall /vercel/path0/node_modules/core-js-pure
13:55:58.683    > node -e "try{require('./postinstall')}catch(e){}"
13:55:58.801    > [email protected] postinstall /vercel/path0/node_modules/ejs
13:55:58.802    > node ./postinstall.js
13:56:01.182    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/webpack-dev-server/node_modules/fsevents):
13:56:01.182    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
13:56:01.191    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/watchpack-chokidar2/node_modules/fsevents):
13:56:01.191    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
13:56:01.202    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: [email protected] (node_modules/fsevents):
13:56:01.202    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
13:56:01.210    added 1985 packages from 812 contributors in 37.99s
13:56:02.556    137 packages are looking for funding
13:56:02.556      run `npm fund` for details
13:56:02.831    Running "npm run build"
13:56:03.100    > [email protected] build /vercel/path0
13:56:03.100    > react-scripts build
13:56:04.846    Creating an optimized production build...
13:56:23.548    Treating warnings as errors because process.env.CI = true.
13:56:23.548    Most CI servers set it automatically.
13:56:23.548    Failed to compile.
13:56:23.549    src/components/Counter.js
13:56:23.549      Line 21:6:  React Hook useEffect has a missing dependency: 'props.timeEnds'. Either include it or remove the dependency array  react-hooks/exhaustive-deps
13:56:23.577    npm ERR! code ELIFECYCLE
13:56:23.578    npm ERR! errno 1
13:56:23.581    npm ERR! [email protected] build: `react-scripts build`
13:56:23.581    npm ERR! Exit status 1
13:56:23.583    npm ERR! 
13:56:23.583    npm ERR! Failed at the [email protected] build script.
13:56:23.583    npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
13:56:23.592    npm ERR! A complete log of this run can be found in:
13:56:23.592    npm ERR!     /vercel/.npm/_logs/2021-03-28T10_56_23_582Z-debug.log
13:56:23.606    Error: Command "npm run build" exited with 1
Undeniable answered 28/3, 2021 at 11:28 Comment(2)
You need to make sure all the warnings in your terminal are cleared/rectified before you build it because builds will fail since process.env.CI = true to ensure only robust code with good practices is deployed.Sulfapyridine
Happy to help! Always remember to read the logs carefully, they exist for a reason! :)Sulfapyridine
H
18

Check whether your codes don't have any warnings. If they have warnings try to fix them and deploy again or ignore them by setting the CI environment variable to false. It would look like this:

CI = false
Heterozygote answered 28/3, 2021 at 12:20 Comment(3)
Anytime @AlperTellioğluHeterozygote
this feels like something you aren't supposed to do... does this hide warnings and force a build? What would setting CI = true do?Wits
It will consider build warnings as errors and won’t deploy the app.Heterozygote
L
10

If you are getting this error:

  1. Go to project setting in vercel.com.
  2. Go to General.
  3. In the "Build & Development Settings", override the Build command and write CI='' npm run build. This solved the error for me.
Linage answered 26/9, 2022 at 18:14 Comment(0)
I
3

Set CI Environment Variable to false Using Vercel CLI

Go to your project directory and then open the terminal and type

$ vercel env add CI

Vercel CLI 24.0.0
? What’s the value of CLI? false
? Add CLI to which Environments (select multiple, press a)? Production, Preview, Development
✅  Added Environment Variable CLI to Project <Project-name> [776ms]

Now, go to your Vercel app => Settings => Environment Variable Their your will see CLI key has a value set to false

Intravasation answered 28/2, 2022 at 8:35 Comment(0)
D
3

Go to project setting in vercel.com. Go to General. In the "Build & Development Settings", override the Build command and write

npm run build

This solved the error for me.

Darceldarcey answered 20/1, 2023 at 13:39 Comment(0)
K
1

You simply you check your package.json in your project folder, check the build script in the json object.

'script':
{
   "dev": "next dev",
             ==>  "build": "next build", 
    "start": "next start",
    "lint": "next lint"
}
Keslie answered 24/6, 2022 at 14:18 Comment(0)
D
1

you probably have already solved this error, but it stays here for new people who might come across this error.

The vercel build tool logs are pretty detailed and normally show where the errors are. In my example I had an error that the eslint wasn't showing, but I found what was the problem in the logs of the vercel build.

In your example, the error that you are facing is declared in the log:

Failed to compile.
13:56:23.549    src/components/Counter.js
13:56:23.549      Line 21:6:  React Hook useEffect has a missing dependency: 'props.timeEnds'. Either include it or remove the dependency array  react-hooks/exhaustive-deps

This is probably the reason it's not building your app. You should try to fix it and then redeploy.

The alternative to set the CI to false in your env also works, but then it will probably deploy your app with some bugs.

Disciplinary answered 6/4, 2023 at 0:57 Comment(0)
A
1

Hello this is after 4 hours of questioning my life i got the main cause of this error its because vercels node version. The vercel's default node version is the latest one But if your project is made lower you will get this error to solve it

go to Setting --> General --> then change the Node.js Version to your project version

enter image description here

Ashworth answered 21/10, 2023 at 19:12 Comment(0)
A
0

I'm godly

For Deployment follow this procedure if you are getting errors...

  1. Run yarn dev in your project folder.
  2. Then run terminal as administrator and cd to your project folder then run vercel build command.
  3. After it finished successfully , delete the folder inside .vercel\output\functions_next\data
  4. Then run vercel deploy prebuilt -> successful (It worked for me)
Actinic answered 23/10, 2022 at 9:14 Comment(0)
P
0

In my case, it was because I had my theme file (theme.ts) in the pages directory.

Vercel didn't flag it in red, but checking the full logs, I saw

Build optimization failed: found page without a React Component as default export in 
pages/theme

See https://nextjs.org/docs/messages/page-without-valid-component for more info.

This made me realise that my theme.ts file shouldn't be where it. Moving it outside pages did the trick.

Primogenial answered 27/3, 2023 at 21:42 Comment(0)
Y
0

If you are getting this error:

  • Go to project setting in vercel.com.
  • Go to General.
  • In the "Build & Development Settings", override the Install command and write this: npm install --force installed-package-name

This solved the error for me.

Yawning answered 7/5, 2023 at 13:54 Comment(0)
A
0

first check if there are any errors by running npm run build if there is no error it will work it worked for me

Ashworth answered 8/9, 2023 at 16:42 Comment(0)
M
0

In my case, deleting package-lock.json removes this error. I was receiving this error on deploying to Vercel while npm run dev, npm run lint, npm run build, vercel dev was running without any error.

Mongolism answered 16/1, 2024 at 12:0 Comment(0)
S
0

None of the provided solutions worked for me. What did work for me was

  1. Go to project setting in Vercel.com.
  2. Go to General tab.
  3. Under the "Build & Development Settings", override the install command with 'npm install ---legacy-peer-deps'
Staff answered 26/2, 2024 at 17:21 Comment(0)
R
0

I solved it simply... I copied everything that was saved inside the file and placed it in another location... I deleted the routes.js file, saved the project and push origin it to github, then created another file with the name routes.js and I put back everything that was there, saved it and push origin it to github... that was the way I solved it, the others weren't working and this one worked

Rationalize answered 9/3, 2024 at 2:33 Comment(1)
As it’s currently written, your answer is unclear. Please edit to add additional details that will help others understand how this addresses the question asked. You can find more information on how to write good answers in the help center.Jumbo
G
0

Instead of override the Build command, you can set the "CI" env variable to false under Settings/Environment Variables.

As already mentioned in other answers, this should probably be done with caution. But in my case it was about a few warnings, so I took the risk.

enter image description here

Gherardo answered 6/7, 2024 at 5:29 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.