1

I am deploying to netlify and I keep running into this error

SyntaxError: Unexpected token ;

My master branch deploys with no errors but my developer branch keeps having the same issue. Here is a picture of my log where it is failing. I can also npm run build locally and there are no errors.

9:00:52 PM: $ npm run build
9:00:52 PM: > [email protected] build /opt/build/repo
9:00:52 PM: > react-scripts build
9:00:53 PM: /opt/build/repo/node_modules/eslint-webpack-plugin/node_modules/jest-worker/build/index.js:110
9:00:53 PM: _ending;
9:00:53 PM: ^
9:00:53 PM: SyntaxError: Unexpected token ;
9:00:53 PM: at Module._compile (internal/modules/cjs/loader.js:723:23)
9:00:53 PM: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
9:00:53 PM: at Module.load (internal/modules/cjs/loader.js:653:32)
9:00:53 PM: at tryModuleLoad (internal/modules/cjs/loader.js:593:12)
9:00:53 PM: at Function.Module._load (internal/modules/cjs/loader.js:585:3)
9:00:53 PM: at Module.require (internal/modules/cjs/loader.js:692:17)
9:00:53 PM: at require (internal/modules/cjs/helpers.js:25:18)
9:00:53 PM: at Object.<anonymous> (/opt/build/repo/node_modules/eslint-webpack-plugin/dist/getESLint.js:9:5)
9:00:53 PM: at Module._compile (internal/modules/cjs/loader.js:778:30)
9:00:53 PM: at Object.Module._extensions..js (internal/modules/cjs/loader.js:789:10)
9:00:53 PM: npm ERR! code ELIFECYCLE
9:00:53 PM: npm ERR! errno 1
9:00:53 PM: npm ERR! [email protected] build: `react-scripts build`
9:00:53 PM: npm ERR! Exit status 1
9:00:53 PM: npm ERR!
9:00:53 PM: npm ERR! Failed at the [email protected] build script.
9:00:53 PM: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
9:00:53 PM: npm ERR! A complete log of this run can be found in:
9:00:53 PM: npm ERR! /opt/buildhome/.npm/_logs/2023-01-05T02_00_53_829Z-debug.log
9:00:53 PM: ​
9:00:53 PM: "build.command" failed 
9:00:53 PM: ────────────────────────────────────────────────────────────────
9:00:53 PM: ​
9:00:53 PM: Error message
9:00:53 PM: Command failed with exit code 1: npm run build (https://ntl.fyi/exit-code-1)
9:00:53 PM: ​
9:00:53 PM: Error location
9:00:53 PM: In Build command from Netlify app:
9:00:53 PM: npm run build
9:00:53 PM: ​
9:00:55 PM: Failed during stage 'building site': Build script returned non-zero exit code: 2 (https://ntl.fyi/exit-code-2)
9:00:53 PM: Resolved config
9:00:53 PM: build:
9:00:53 PM: command: npm run build
9:00:53 PM: commandOrigin: ui
9:00:53 PM: environment:
9:00:53 PM: - REACT_APP_GA_TRACKING
9:00:53 PM: - REACT_APP_ORGID
9:00:53 PM: publish: /opt/build/repo/build
9:00:53 PM: publishOrigin: ui
9:00:54 PM: Caching artifacts
9:00:54 PM: Started saving node modules
9:00:54 PM: Finished saving node modules
9:00:54 PM: Started saving build plugins
9:00:54 PM: Finished saving build plugins
9:00:54 PM: Started saving pip cache
9:00:54 PM: Finished saving pip cache
9:00:54 PM: Started saving emacs cask dependencies
9:00:54 PM: Finished saving emacs cask dependencies
9:00:54 PM: Started saving maven dependencies
9:00:54 PM: Finished saving maven dependencies
9:00:54 PM: Started saving boot dependencies
9:00:54 PM: Finished saving boot dependencies
9:00:54 PM: Started saving rust rustup cache
9:00:54 PM: Finished saving rust rustup cache
9:00:54 PM: Started saving go dependencies
9:00:54 PM: Finished saving go dependencies
9:00:55 PM: Cached ruby version 2.6.2
9:00:55 PM: Build failed due to a user error: Build script returned non-zero exit code: 2
9:00:55 PM: Failing build: Failed to build site
9:00:55 PM: Finished processing build request in 53.449896862s
asked Jan 5, 2023 at 2:13
5
  • 1
    This means your "developer" branch has a build error. Try to run npm run build locally and see if there's anything useful. Commented Jan 5, 2023 at 2:15
  • I did that and it compiles successfully. Commented Jan 5, 2023 at 2:18
  • Are you sure you were on develop branch? If so, check the npm versions of your local and Netlify. Commented Jan 5, 2023 at 2:19
  • I was for certain on the developer branch. I"m not sure how to check the npm version in netlify but I'm using 8.19.2 locally Commented Jan 5, 2023 at 2:33
  • 8.19.2 is very old, so I expect it wouldn't match Netlify's npm version. You can consider upgrading your local version or downgrade Netlify's npm version. Commented Jan 5, 2023 at 2:34

1 Answer 1

4

As you mentioned in your comment, the issue is Netlify's npm version is much higher than your local environment and thus some syntax of your code is deprecated and no longer understood by the (newer) npm.

It is recommended to upgrade your local npm version, but if it's not possible right now, you can downgrade Netlify's npm version.

In order to set Netlify's npm version, you can use NODE_VERSION environment variable.

Go to https://app.netlify.com/sites/<site-name>/settings/env#environment-variables and add NODE_VERSION variable and set it as your local npm version.

answered Jan 5, 2023 at 2:54
Sign up to request clarification or add additional context in comments.

1 Comment

I found this to be the error. I just told netlify what npm version to use in the env variables setup and it worked.

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.