Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gatsby build failing with Unexpected token error but no other details or stacktrace #32705

Closed
2 tasks done
chhpt opened this issue Aug 5, 2021 · 18 comments
Closed
2 tasks done
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby

Comments

@chhpt
Copy link

chhpt commented Aug 5, 2021

Preliminary Checks

Description

It works well in development mode, but build fail and there is no other error details.

failed Building production JavaScript and CSS bundles - 1.742s

 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

Unexpected token (12:287)

File: .cache/production-app.js:12:287

Reproduction Link

https://github.com/chhpt/gatsby-ts-starter

Steps to Reproduce

  1. install dependencies: yarn
  2. yarn run build

Expected Result

Build success

Actual Result

Build fail

Environment

macOS 11.5, node 14.16.0, npm 6.14.11

Config Flags

No

@chhpt chhpt added the type: bug An issue or pull request relating to a bug in Gatsby label Aug 5, 2021
@gatsbot gatsbot bot added the status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer label Aug 5, 2021
@mwskwong
Copy link

mwskwong commented Aug 5, 2021

Duplicate of #32704

@mwskwong
Copy link

mwskwong commented Aug 5, 2021

Similar issue on my project. This is a hard failure in the production build. Yet, the development build doesn't seem to be affected.
https://github.com/matthewkwong2/resume-gatsby/tree/next

A bit more details

Error parsing bundle asset "C:\Users\kmw111\Documents\project\resume-gatsby\public\polyfill-0fd01837a62087bcf144.js": no such file
Error parsing bundle asset "C:\Users\kmw111\Documents\project\resume-gatsby\public\app-c6f931d9df56eae7c132.js": no such file
Error parsing bundle asset "C:\Users\kmw111\Documents\project\resume-gatsby\public\webpack-runtime-883fcbcd518ee8384a9c.js": no such file

No bundles were parsed. Analyzer will show only original module sizes from stats file.

Webpack Bundle Analyzer is started at http://127.0.0.1:3001
Use Ctrl+C to close it
failed Building production JavaScript and CSS bundles - 31.412s

 ERROR #98123  WEBPACK

Generating JavaScript bundles failed

Unexpected token (12:223)

File: .cache\production-app.js:12:223

Gatsby Info

  System:
    OS: Windows 10 10.0.19042
    CPU: (12) x64 Intel(R) Core(TM) i7-8700 CPU @ 3.20GHz
  Binaries:
    Node: 14.17.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.22.5 - C:\Program Files (x86)\Yarn\bin\yarn.CMD
    npm: 7.14.0 - C:\Program Files\nodejs\npm.CMD
  Languages:
    Python: 3.9.5
  Browsers:
    Chrome: 92.0.4515.131
    Edge: Spartan (44.19041.423.0), Chromium (92.0.902.62)
  npmPackages:
    gatsby: ^3.11.0 => 3.11.0 
    gatsby-plugin-emotion: ^6.11.0 => 6.11.0 
    gatsby-plugin-image: ^1.11.0 => 1.11.0 
    gatsby-plugin-manifest: ^3.11.0 => 3.11.0 
    gatsby-plugin-offline: ^4.11.0 => 4.11.0 
    gatsby-plugin-react-helmet: ^4.11.0 => 4.11.0 
    gatsby-plugin-robots-txt: ^1.6.8 => 1.6.8 
    gatsby-plugin-root-import: ^2.0.6 => 2.0.6 
    gatsby-plugin-sharp: ^3.11.0 => 3.11.0 
    gatsby-plugin-sitemap: ^4.7.0 => 4.7.0 
    gatsby-plugin-webpack-bundle-analyser-v2: ^1.1.24 => 1.1.24 
    gatsby-source-filesystem: ^3.11.0 => 3.11.0 
    gatsby-transformer-sharp: ^3.11.0 => 3.11.0 

Flags

FAST_DEV: true,
PARALLEL_QUERY_RUNNING: true
PARALLEL_SOURCING: true

p.s. same error when no flags are used.

@LekoArts LekoArts added topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) and removed status: triage needed Issue or pull request that need to be triaged and assigned to a reviewer labels Aug 5, 2021
@chenxizhang
Copy link

chenxizhang commented Aug 5, 2021

same issue here, it works fine yesterday, and I don't make any changes on the code

just have this error, without any details information, ERROR #98123 WEBPACK

`failed Building production JavaScript and CSS bundles - 2.515s
ERROR #98123 WEBPACK

Generating JavaScript bundles failed
Unexpected token (12:287)
File: .cache/production-app.js:12:287
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! qiangzi@0.1.0 build: gatsby build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the qiangzi@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.`

System:
OS: Linux 5.4 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (4) x64 Intel(R) Xeon(R) Platinum 8272CL CPU @ 2.60GHz
Shell: 5.0.3 - /bin/bash
Binaries:
Node: 14.17.3 - /usr/local/share/nvm/versions/node/v14.17.3/bin/node
Yarn: 1.22.5 - /usr/bin/yarn
npm: 6.14.13 - /usr/local/share/nvm/versions/node/v14.17.3/bin/npm
Languages:
Python: 3.8.11 - /usr/local/bin/python
npmPackages:
gatsby: ^3.11.0 => 3.11.0
gatsby-plugin-image: ^1.6.0 => 1.11.0
gatsby-plugin-manifest: ^3.6.0 => 3.11.0
gatsby-plugin-offline: ^4.6.0 => 4.11.0
gatsby-plugin-react-helmet: ^4.6.0 => 4.11.0
gatsby-plugin-react-i18next: ^1.1.1 => 1.1.1
gatsby-plugin-sharp: ^3.6.0 => 3.11.0
gatsby-source-filesystem: ^3.6.0 => 3.11.0
gatsby-transformer-sharp: ^3.6.0 => 3.11.0

@LekoArts LekoArts added the status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. label Aug 5, 2021
@LekoArts
Copy link
Contributor

LekoArts commented Aug 5, 2021

Hi!

I've cloned the starter https://github.com/chhpt/gatsby-ts-starter, removed the yarn.lock file, run yarn and then yarn build and I don't see any issues:

image

Can you please provide a reproduction showing this issue, including the steps necessary?

@flikteoh
Copy link

flikteoh commented Aug 5, 2021

Hi

I'm not sure what are the easiest way to create reproduction on this issue.

But uninstalling and reinstalling gatsby-cli globally solved the error and seems to be back to normal for now (tested this on two sites).

@chhpt
Copy link
Author

chhpt commented Aug 5, 2021

@LekoArts @flikteoh Hi, I delete the yarn.lock file and the problem has disappeared. I found that @babel/plugin-transform-react-display-name has a update. So the problem may caused by it.

@chenxizhang
Copy link

@LekoArts I have a private repository in Github, but I can invite you by the live share in VS Code if need. let me know...

@mwskwong
Copy link

mwskwong commented Aug 5, 2021

@LekoArts @flikteoh Hi, I delete the yarn.lock file and the problem has disappeared. I found that @babel/plugin-transform-react-display-name has a update. So the problem may caused by it.

It appears to be the case. I'm not facing this error anymore. And yes, there are also a few packages updated on my side, including @babel/standalone and @babel/plugin-transform-react-display-name. It might be the cause.

@LekoArts
Copy link
Contributor

LekoArts commented Aug 5, 2021

Can you run yarn why @babel/plugin-transform-react-display-name in your repo @chenxizhang ?

As others pointed out it might have been caused by babel/babel#13501 which was just reverted in babel/babel#13637 and released in babel/babel@546e3d9#diff-01ecfc1ff84980d33a414eec403fcb86a6c9f61979ac6163753744719b8110ed (7.15.1)

@mwskwong
Copy link

mwskwong commented Aug 5, 2021

Can you run yarn why @babel/plugin-transform-react-display-name in your repo @chenxizhang ?

As others pointed out it might have been caused by babel/babel#13501 which was just reverted in babel/babel#13637 and released in babel/babel@546e3d9#diff-01ecfc1ff84980d33a414eec403fcb86a6c9f61979ac6163753744719b8110ed (7.15.1)

@babel/plugin-transform-react-display-name@7.15.1
node_modules/@babel/plugin-transform-react-display-name
  @babel/plugin-transform-react-display-name@"^7.14.5" from @babel/preset-react@7.14.5
  node_modules/@babel/preset-react
    @babel/preset-react@"^7.14.0" from babel-preset-gatsby@1.11.0
    node_modules/babel-preset-gatsby
      babel-preset-gatsby@"^1.11.0" from gatsby@3.11.0
      node_modules/gatsby
        gatsby@"^3.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from babel-plugin-remove-graphql-queries@3.11.0
        node_modules/babel-plugin-remove-graphql-queries
          babel-plugin-remove-graphql-queries@"^3.11.0" from gatsby@3.11.0
          babel-plugin-remove-graphql-queries@"^3.11.0" from gatsby-plugin-image@1.11.0
          node_modules/gatsby-plugin-image
            gatsby-plugin-image@"^1.11.0" from the root project
          babel-plugin-remove-graphql-queries@"^3.11.0" from gatsby-plugin-typescript@3.11.0
          node_modules/gatsby-plugin-typescript
            gatsby-plugin-typescript@"^3.11.0" from gatsby@3.11.0
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-emotion@6.11.0
        node_modules/gatsby-plugin-emotion
          gatsby-plugin-emotion@"^6.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-image@1.11.0
        node_modules/gatsby-plugin-image
          gatsby-plugin-image@"^1.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-manifest@3.11.0
        node_modules/gatsby-plugin-manifest
          gatsby-plugin-manifest@"^3.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-offline@4.11.0
        node_modules/gatsby-plugin-offline
          gatsby-plugin-offline@"^4.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-page-creator@3.11.0
        node_modules/gatsby-plugin-page-creator
          gatsby-plugin-page-creator@"^3.11.0" from gatsby@3.11.0
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-react-helmet@4.11.0
        node_modules/gatsby-plugin-react-helmet
          gatsby-plugin-react-helmet@"^4.11.0" from the root project
        peer gatsby@"^3.0.0 || ^2.0.0" from gatsby-plugin-robots-txt@1.6.8
        node_modules/gatsby-plugin-robots-txt
          gatsby-plugin-robots-txt@"^1.6.8" from the root project
        peer gatsby@">=1" from gatsby-plugin-root-import@2.0.6
        node_modules/gatsby-plugin-root-import
          dev gatsby-plugin-root-import@"^2.0.6" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-sharp@3.11.0
        node_modules/gatsby-plugin-sharp
          gatsby-plugin-sharp@"^3.11.0" from the root project
          peer gatsby-plugin-sharp@"^3.0.0-next.0" from gatsby-plugin-image@1.11.0
          node_modules/gatsby-plugin-image
            gatsby-plugin-image@"^1.11.0" from the root project
          peer gatsby-plugin-sharp@"^3.0.0-next.0" from gatsby-transformer-sharp@3.11.0
          node_modules/gatsby-transformer-sharp
            gatsby-transformer-sharp@"^3.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-sitemap@4.7.0
        node_modules/gatsby-plugin-sitemap
          gatsby-plugin-sitemap@"^4.7.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-typescript@3.11.0
        node_modules/gatsby-plugin-typescript
          gatsby-plugin-typescript@"^3.11.0" from gatsby@3.11.0
        peer gatsby@"^3.0.0-next.0" from gatsby-plugin-utils@1.11.0
        node_modules/gatsby-plugin-utils
          gatsby-plugin-utils@"^1.11.0" from gatsby@3.11.0
          gatsby-plugin-utils@"^1.11.0" from gatsby-plugin-manifest@3.11.0
          node_modules/gatsby-plugin-manifest
            gatsby-plugin-manifest@"^3.11.0" from the root project
          gatsby-plugin-utils@"^1.11.0" from gatsby-plugin-sharp@3.11.0
          node_modules/gatsby-plugin-sharp
            gatsby-plugin-sharp@"^3.11.0" from the root project
            peer gatsby-plugin-sharp@"^3.0.0-next.0" from gatsby-plugin-image@1.11.0
            node_modules/gatsby-plugin-image
              gatsby-plugin-image@"^1.11.0" from the root project
            peer gatsby-plugin-sharp@"^3.0.0-next.0" from gatsby-transformer-sharp@3.11.0
            node_modules/gatsby-transformer-sharp
              gatsby-transformer-sharp@"^3.11.0" from the root project
        peer gatsby@"^2.0.0 || ^3.0.0" from gatsby-plugin-webpack-bundle-analyser-v2@1.1.24
        node_modules/gatsby-plugin-webpack-bundle-analyser-v2
          dev gatsby-plugin-webpack-bundle-analyser-v2@"^1.1.24" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-source-filesystem@3.11.0
        node_modules/gatsby-source-filesystem
          gatsby-source-filesystem@"^3.11.0" from the root project
          peer gatsby-source-filesystem@"^3.0.0-next.0" from gatsby-plugin-image@1.11.0
          node_modules/gatsby-plugin-image
            gatsby-plugin-image@"^1.11.0" from the root project
        peer gatsby@"^3.0.0-next.0" from gatsby-transformer-sharp@3.11.0
        node_modules/gatsby-transformer-sharp
          gatsby-transformer-sharp@"^3.11.0" from the root project

I'm using npm, so I ran npm why instead

@chenxizhang
Copy link

Can you run yarn why @babel/plugin-transform-react-display-name in your repo @chenxizhang ?

As others pointed out it might have been caused by babel/babel#13501 which was just reverted in babel/babel#13637 and released in babel/babel@546e3d9#diff-01ecfc1ff84980d33a414eec403fcb86a6c9f61979ac6163753744719b8110ed (7.15.1)

Thanks, I ran the cmd, the result is

yarn why v1.22.5
[1/4] Why do we have the module "@babel/plugin-transform-react-display-name"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
=> Found "@babel/plugin-transform-react-display-name@7.15.1"
info Reasons this module exists

  • "gatsby#babel-preset-gatsby#@babel#preset-react" depends on it
  • Hoisted from "gatsby#babel-preset-gatsby#@babel#preset-react#@babel#plugin-transform-react-display-name"
    info Disk size without dependencies: "20KB"
    info Disk size with unique dependencies: "40KB"
    info Disk size with transitive dependencies: "40KB"
    info Number of shared dependencies: 1
    Done in 0.85s.

@LekoArts
Copy link
Contributor

LekoArts commented Aug 5, 2021

Then you shouldn't have the issue anymore. I've used yarn resolutions to force the version to 7.15.0 and I see the error. After forcing to 7.15.1 the error goes away 👍


So if you see the error please update your packages and check that you have @babel/plugin-transform-react-display-name@7.15.1 installed or anything below 7.15.0

@LekoArts LekoArts closed this as completed Aug 5, 2021
@chenxizhang
Copy link

Sorry, I still have this issue @LekoArts

image

@chenxizhang
Copy link

@LekoArts I tried the yarn clean first, and then it works fine

What's the magic..

@LekoArts
Copy link
Contributor

LekoArts commented Aug 5, 2021

Removing caches or node_modules sometimes solves it 🤷

@chenxizhang
Copy link

It's crazy, I can run npm run build on the dev machine, but it will fail on the github actions workflow

image

@chenxizhang
Copy link

I tried to force the github actions to use "yarn build", not the "npm run build", and it works...

@nrandell
Copy link
Contributor

nrandell commented Aug 5, 2021

Had this same issue. Made sure I had @babel/plugin-transform-react-display-name@7.15.1 installed, cleared .cache/webpack and it build ok.

On gatsby cloud had to do a full clear cache and restart, but now all working.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
status: needs reproduction This issue needs a simplified reproduction of the bug for further troubleshooting. topic: core Relates to Gatsby's core (e.g. page loading, reporter, state machine) type: bug An issue or pull request relating to a bug in Gatsby
Projects
None yet
Development

No branches or pull requests

6 participants