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

Netlify deployment fails (esbuild error) #73

Closed
Pagebakers opened this issue Dec 16, 2021 · 4 comments
Closed

Netlify deployment fails (esbuild error) #73

Pagebakers opened this issue Dec 16, 2021 · 4 comments
Labels
blocked-upstream This issue is currently blocked by another problem/limitation in an upstream package meta: stale

Comments

@Pagebakers
Copy link

Pagebakers commented Dec 16, 2021

I've been strugling all day to get deployments on Netlify to work, hopefully somebody can point me in the right direction here.

This error is thrown once contentlayer starts building.

5:48:19 PM: This shouldn't happen. Seems like esbuild watcher wasn't running (yet).
5:48:19 PM: UnknownEsbuildError {
5:48:19 PM:   error: Error: Build failed with 1 error:
5:48:19 PM:   /opt/build/repo/website/node_modules/esbuild/lib/main.js:239:12: error: Invalid option in build() call: "jsx"
5:48:19 PM:       at failureErrorWithLog (/opt/build/repo/website/node_modules/esbuild/lib/main.js:1443:15)
5:48:19 PM:       at /opt/build/repo/website/node_modules/esbuild/lib/main.js:1012:18
5:48:19 PM:       at /opt/build/repo/website/node_modules/esbuild/lib/main.js:1007:9
5:48:19 PM:       at /opt/build/repo/website/node_modules/esbuild/lib/main.js:606:9
5:48:19 PM:       at handleIncomingPacket (/opt/build/repo/website/node_modules/esbuild/lib/main.js:703:9)
5:48:19 PM:       at Socket.readFromStdout (/opt/build/repo/website/node_modules/esbuild/lib/main.js:573:7)
5:48:19 PM:       at Socket.emit (node:events:390:28)
5:48:19 PM:       at Socket.emit (node:domain:475:12)
5:48:19 PM:       at addChunk (node:internal/streams/readable:315:12)
5:48:19 PM:       at readableAddChunk (node:internal/streams/readable:289:9) {
5:48:19 PM:     errors: [ [Object] ],
5:48:19 PM:     warnings: []
5:48:19 PM:   },
5:48:19 PM:   _tag: 'UnknownEsbuildError',
5:48:19 PM:   toString: [Function (anonymous)]
5:48:19 PM: }

I've updated the netlify next plugin to the latest RC as stated in #68 this solves the syntax error, but unfortunately not the esbuild error.

Also tried running contentlayer build manually, this results in the same error on Netlify, locally this works.

Versions:

  • Node 16.3.1
  • Yarn 1.22.10
  • Contentlayer 0.0.33
  • Next.js 12.0.7

The Next.js app is build from a subdirectory.

Using the netlify-cli to build the app locally works fine and i'm able to publish the site.

@Pagebakers
Copy link
Author

Pagebakers commented Dec 16, 2021

Finally figured out a couple of issues.

  1. Netlify wasn't using Yarn, this seemed to fix the above error.

Contentlayer has issues finding the correct path if you build a monorepo with Turborepo, I had to make these adjustments to make it work.

//next.config.js
// Make sure this only runs on dev environments.

const isNextDev = process.argv.includes('dev')

if (isNextDev) {
  config = withContentlayer()(config)
}

module.exports = config
// package.json
{
"scripts": {
    "build": "yarn gen:contentlayer && next build",
    "gen:contentlayer": "contentlayer build --config ./website/contentlayer.config.ts --verbose"
    }
}

Notice the website folder I had to add. There must be a better way to do this though.

@schickling
Copy link
Collaborator

Probably related to vercel/turborepo#485. I'll do some further investigation once addressed by Turborepo.

@schickling schickling added the blocked-upstream This issue is currently blocked by another problem/limitation in an upstream package label Jan 3, 2022
@schickling
Copy link
Collaborator

@Pagebakers nos that there's an even simpler workaround for this problem:

// package.json
  "scripts": {
     // ...
    "build": "INIT_CWD=$PWD next build",
    // ...
  },

@stale
Copy link

stale bot commented Apr 2, 2022

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the meta: stale label Apr 2, 2022
@stale stale bot closed this as completed Apr 12, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
blocked-upstream This issue is currently blocked by another problem/limitation in an upstream package meta: stale
Projects
None yet
Development

No branches or pull requests

2 participants