Why do i see the error SyntaxError: Unexpected token { on Nuxt generate

Hi there!

Iโ€™ve tried to deploy my website for some time now. This is the error, i really cant find any information about it on the web or here.

This is with Nuxt.

10:47:14 PM: Build ready to start
10:47:18 PM: build-image version: 8e315e54bc4032a32e73290be556cde4f8348c12
10:47:18 PM: build-image tag: v2.8.2
10:47:18 PM: buildbot version: 45cd00068410d70db72c9672cdd014995488e12a
10:47:18 PM: No cache source specified, skip fetching cache
10:47:18 PM: Starting to prepare the repo for build
10:47:18 PM: No cached dependencies found. Cloning fresh repo
10:47:18 PM: git clone https://github.com/devpaps/rellow
10:47:19 PM: Preparing Git Reference refs/heads/master
10:47:20 PM: Starting build script
10:47:20 PM: Installing dependencies
10:47:21 PM: Downloading and installing node v8.17.0...
10:47:21 PM: Downloading https://nodejs.org/dist/v8.17.0/node-v8.17.0-linux-x64.tar.xz...
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: #
10:47:22 PM: 2
10:47:22 PM: 5
10:47:22 PM: .
10:47:22 PM: 1
10:47:22 PM: %
10:47:22 PM: 
################
10:47:22 PM: ########################################################
10:47:22 PM:  100.0%
10:47:22 PM: Computing checksum with sha256sum
10:47:22 PM: Checksums matched!
10:47:24 PM: Now using node v8.17.0 (npm v6.13.4)
10:47:24 PM: Attempting ruby version 2.3.6, read from environment
10:47:26 PM: Using ruby version 2.3.6
10:47:26 PM: Using PHP version 5.6
10:47:26 PM: Started restoring cached node modules
10:47:26 PM: Finished restoring cached node modules
10:47:26 PM: Installing NPM modules using NPM version 6.13.4
10:47:56 PM: > node-sass@4.14.1 install /opt/build/repo/node_modules/node-sass
10:47:56 PM: > node scripts/install.js
10:47:57 PM: Downloading binary from https://github.com/sass/node-sass/releases/download/v4.14.1/linux-x64-57_binding.node
10:47:58 PM: Download complete
10:47:58 PM: Binary saved to /opt/build/repo/node_modules/node-sass/vendor/linux-x64-57/binding.node
10:47:58 PM: Caching binary to /opt/buildhome/.npm/node-sass/4.14.1/linux-x64-57_binding.node
10:47:58 PM: > core-js@3.6.5 postinstall /opt/build/repo/node_modules/@babel/node/node_modules/core-js
10:47:58 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:47:58 PM: Thank you for using core-js ( https://github.com/zloirock/core-js ) for polyfilling JavaScript standard library!
10:47:58 PM: The project needs your help! Please consider supporting of core-js on Open Collective or Patreon: 
10:47:58 PM: > https://opencollective.com/core-js 
10:47:58 PM: > https://www.patreon.com/zloirock 
10:47:58 PM: Also, the author of core-js ( https://github.com/zloirock ) is looking for a good job -)
10:47:58 PM: > core-js@2.6.11 postinstall /opt/build/repo/node_modules/core-js
10:47:58 PM: > node -e "try{require('./postinstall')}catch(e){}"
10:47:58 PM: > ejs@2.7.4 postinstall /opt/build/repo/node_modules/ejs
10:47:58 PM: > node ./postinstall.js
10:47:58 PM: Thank you for installing EJS: built with the Jake JavaScript build tool (https://jakejs.com/)
10:47:58 PM: > scrollreveal@4.0.7 postinstall /opt/build/repo/node_modules/scrollreveal
10:47:58 PM: > node -e "console.log('\u001b[35m\u001b[1mLove ScrollReveal? ๐Ÿ”‘  Buy a license!\u001b[22m\u001b[35m\n >> \u001b[33mhttps://scrollrevealjs.org/pricing/\u001b[0m\n')"
10:47:58 PM: Love ScrollReveal? ๐Ÿ”‘  Buy a license!
10:47:58 PM:  >> https://scrollrevealjs.org/pricing/
10:47:59 PM: > gifsicle@4.0.1 postinstall /opt/build/repo/node_modules/gifsicle
10:47:59 PM: > node lib/install.js
10:47:59 PM:   โœ” gifsicle pre-build test passed successfully
10:47:59 PM: > jpegtran-bin@4.0.0 postinstall /opt/build/repo/node_modules/jpegtran-bin
10:47:59 PM: > node lib/install.js
10:47:59 PM:   โœ” jpegtran pre-build test passed successfully
10:47:59 PM: > optipng-bin@5.1.0 postinstall /opt/build/repo/node_modules/optipng-bin
10:47:59 PM: > node lib/install.js
10:48:00 PM:   โœ” optipng pre-build test passed successfully
10:48:00 PM: > pngquant-bin@5.0.2 postinstall /opt/build/repo/node_modules/pngquant-bin
10:48:00 PM: > node lib/install.js
10:48:00 PM:   โœ” pngquant pre-build test passed successfully
10:48:00 PM: > node-sass@4.14.1 postinstall /opt/build/repo/node_modules/node-sass
10:48:00 PM: > node scripts/build.js
10:48:00 PM: Binary found at /opt/build/repo/node_modules/node-sass/vendor/linux-x64-57/binding.node
10:48:00 PM: Testing binary
10:48:01 PM: Binary is fine
10:48:01 PM: > nodemon@2.0.4 postinstall /opt/build/repo/node_modules/nodemon
10:48:01 PM: > node bin/postinstall || exit 0
10:48:01 PM: Love nodemon? You can now support the project via the open collective:
10:48:01 PM:  > https://opencollective.com/nodemon/donate
10:48:01 PM: > nuxt@2.14.4 postinstall /opt/build/repo/node_modules/nuxt
10:48:01 PM: > opencollective || exit 0
10:48:01 PM:                                      :-:
10:48:01 PM:                                    .==-+:
10:48:01 PM:                                   .==. :+- .-=-
10:48:01 PM:                                  .==.   :==++-+=.
10:48:01 PM:                                 :==.     -**: :+=.
10:48:01 PM:                                :+-      :*+++. .++.
10:48:01 PM:                               :+-      -*= .++: .=+.
10:48:01 PM:                              -+:      =*-   .+*: .=+:
10:48:01 PM:                             -+:     .=*-     .=*-  =+:
10:48:01 PM:                           .==:     .+*:        -*-  -+-
10:48:01 PM:                          .=+:.....:+*-.........:=*=..=*-
10:48:01 PM:                          .-=------=++============++====:
10:48:01 PM:                           Thanks for installing nuxtjs
10:48:01 PM:                  Please consider donating to our open collective
10:48:01 PM:                         to help us maintain this package.
10:48:01 PM:                            Number of contributors: 229
10:48:01 PM:                               Number of backers: 360
10:48:01 PM:                             Annual budget: US$ 78,942
10:48:01 PM:                            Current balance: US$ 33,900
10:48:01 PM:                  Donate: https://opencollective.com/nuxtjs/donate
10:48:04 PM: npm
10:48:04 PM: WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/watchpack-chokidar2/node_modules/fsevents):
10:48:04 PM: npm
10:48:04 PM: WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:48:04 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_modules/@babel/cli/node_modules/fsevents):
10:48:04 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:48:04 PM: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_modules/fsevents):
10:48:04 PM: npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
10:48:04 PM: added 1912 packages from 787 contributors and audited 1858 packages in 37.019s
10:48:06 PM: 63 packages are looking for funding
10:48:06 PM:   run `npm fund` for details
10:48:06 PM: found 0 vulnerabilities
10:48:06 PM: NPM modules installed
10:48:06 PM: Started restoring cached go cache
10:48:06 PM: Finished restoring cached go cache
10:48:06 PM: Installing Go version 1.10
10:48:11 PM: unset GOOS;
10:48:11 PM: unset GOARCH;
10:48:11 PM: export GOROOT='/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64';
10:48:11 PM: export PATH="/opt/buildhome/.gimme_cache/versions/go1.10.linux.amd64/bin:${PATH}";
10:48:11 PM: go version >&2;
10:48:11 PM: export GIMME_ENV="/opt/buildhome/.gimme_cache/env/go1.10.linux.amd64.env"
10:48:11 PM: go version go1.10 linux/amd64
10:48:11 PM: Installing missing commands
10:48:11 PM: Verify run directory
10:48:11 PM: Executing user command: npm run generate
10:48:11 PM: > rellow_site@1.0.0 generate /opt/build/repo
10:48:11 PM: > nuxt generate
10:48:12 PM:  FATAL  Unexpected token {
10:48:12 PM:   } catch {
10:48:12 PM:   ^
10:48:12 PM:   SyntaxError: Unexpected token {
10:48:12 PM:   at Object.Module._extensions..js (module.js:664:10)
10:48:12 PM:   at Object.Module._extensions..js (module.js:664:10)
10:48:12 PM:    โ•ญโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฎ
10:48:12 PM:    โ”‚                                     โ”‚
10:48:12 PM:    โ”‚   โœ– Nuxt Fatal Error                โ”‚
10:48:12 PM:    โ”‚                                     โ”‚
10:48:12 PM:    โ”‚   SyntaxError: Unexpected token {   โ”‚
10:48:12 PM:    โ”‚                                     โ”‚
10:48:12 PM:    โ•ฐโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ•ฏ
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM: code
10:48:12 PM:  ELIFECYCLE
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM: errno
10:48:12 PM:  1
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM:  rellow_site@1.0.0 generate: `nuxt generate`
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM:  Exit status 1
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM:  Failed at the rellow_site@1.0.0 generate script.
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM:  This is probably not a problem with npm. There is likely additional logging output above.
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM:  A complete log of this run can be found in:
10:48:12 PM: npm
10:48:12 PM: ERR!
10:48:12 PM:      /opt/buildhome/.npm/_logs/2020-09-01T20_48_12_475Z-debug.log
10:48:12 PM: Skipping functions preparation step: no functions directory set
10:48:12 PM: Caching artifacts
10:48:12 PM: Started saving node modules
10:48:12 PM: Finished saving node modules
10:48:12 PM: Started saving pip cache
10:48:12 PM: Finished saving pip cache
10:48:12 PM: Started saving emacs cask dependencies
10:48:12 PM: Finished saving emacs cask dependencies
10:48:12 PM: Started saving maven dependencies
10:48:12 PM: Finished saving maven dependencies
10:48:12 PM: Started saving boot dependencies
10:48:12 PM: Finished saving boot dependencies
10:48:12 PM: Started saving go dependencies
10:48:13 PM: Finished saving go dependencies
10:48:16 PM: Error running command: Build script returned non-zero exit code: 1
10:48:16 PM: Failing build: Failed to build site
10:48:16 PM: failed during stage 'building site': Build script returned non-zero exit code: 1
10:48:16 PM: Finished processing build request in 58.738588375s

hmm, definitely seems like a code error - seemingly not in code you wrote.

Does this build locally?

Yes, it does. Both yarn dev and yarn generate. Isnโ€™t there a log file from netlify that i can look at which file the error is at?

Nobody know what the problem is?

iโ€™m sorry, devpaps - i donโ€™t have any further advice for you at the moment.

have you tried asking in one of the dedicated places for nuxt support?

I encountered this same problem, when upgrading to Nuxt 2.14. It was resolved by explicitly setting the node version by setting NODE_VERSION environment variable to match what I am using in development. If not set, Netlify uses version 8, but I have already upgraded to Node 12 during development.

2 Likes

This solved my problem! Thanks again. I thought I should share my issue on Nuxt to, it was resolved there too.

1 Like