Closed Rafcin closed 2 years ago
Same issue, building locally just fine but failing on netlify
@panbanda I've been looking at it for weeks. I genuinely don't know why.
I actually started encountering it when I installed my sentry/nextjs package. It went away after that. After reading sentry says next12 isn't supported so makes me think its a configuration override that isn't working.
I removed Sentry as well and that resolved a bunch of issues. Currently I'm stuck with Amplify running npx serverless. It terminates without reason.
On Thu, Nov 25, 2021, 1:36 AM Jonathan Reyes @.***> wrote:
I actually started encountering it when I installed my sentry/nextjs package. It went away after that. After reading sentry says next12 isn't supported so makes me think its a configuration override that isn't working.
— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/vercel/next.js/issues/31555#issuecomment-979027188, or unsubscribe https://github.com/notifications/unsubscribe-auth/ACQCG6YCDNPKJTSQEXJ26NDUNX7RNANCNFSM5IIDSSZA .
I had this same problem, I fixed it by moving the yarn install
part from preBuild.commands
to the start of build.commands
, I also changed from node 14 to node 12.
Hey @Rafcin, did you try updating to the latest version of @sentry/nextjs
?
We had issues with our SDK package working well with Next 12 which we resolved in our SDK version 6.16.1
. Can you give it another try?
@vladanpaunovic I forgot I created this issue on the Next repo. The deployment issues had been caused by a mix of Next 12, NX, and Sentry. At the moment Next 12 and Sentry seem to work fine, and the Amplify issue boiled down to the Amplify build system not yet supporting Next 12 and being unable to properly deploy the NX output. I deployed a test application on Vercel that uses Next 12, Sentry, and NX. It deployed perfectly after updating to Next 12.0.6.
I still encounter this issue with @sentry/nextjs 6.17.2 and next 12.0.9
ah nvm fixed it by upgrading netlify nextjs plugin to 4.2.1
@juice0x Sentry works for you with 6.17.2? I tried to add Sentry back and it kept throwing the errors it couldn't understand the Next license file. This build issue only occurs when deploying and I'm using Next 11.
@Rafcin If you can, try updating to Next 12. Having the latest versions of netlify nextjs plugin, @sentry/nextjs, and next 12 fixed the issue for me
Well i'm running into a build issue that I've seen before I just still don't understand the issue. It seems it's not Sentry, I just disabled that, I also added @next/mdx which I think messes it up and I don't know what it is but I get this issue when I build with serverless and deploy on Amplify and this only happened when I added sentry and mdx.
It's always Failed to compile. ../../node_modules/next/dist/compiled/@vercel/nft/LICENSE
Tasks: 10 successful, 10 total
Cached: 0 cached, 10 total
2022-02-08T22:58:42.080Z [INFO]: Time: 3m11.929s
2022-02-08T22:58:42.113Z [INFO]: Done in 192.06s.
2022-02-08T22:58:42.121Z [INFO]: # Executing command: cd apps/fox
2022-02-08T22:58:42.146Z [INFO]: # Executing command: cp config/serverless.yml serverless.yml
2022-02-08T22:58:42.153Z [INFO]: Starting SSR Build...
2022-02-08T23:01:48.574Z [ERROR]: Error: Command failed with exit code 1: node_modules/.bin/next build
warn - You have enabled experimental feature(s).
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
(node:3559) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3559) [DEP_WEBPACK_CHUNK_ADD_MODULE] DeprecationWarning: Chunk.addModule: Use new ChunkGraph API
Failed to compile.
../../node_modules/next/dist/compiled/@vercel/nft/LICENSE
Module parse failed: Unexpected token (1:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> Copyright 2019 Vercel, Inc.
|
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
> Build error occurred
Error: > Build failed because of webpack errors
at /codebuild/output/src217768232/src/fox/node_modules/next/dist/build/index.js:397:19
at async Span.traceAsyncFn (/codebuild/output/src217768232/src/fox/node_modules/next/dist/telemetry/trace/trace.js:60:20)
at async Object.build [as default] (/codebuild/output/src217768232/src/fox/node_modules/next/dist/build/index.js:77:25)
info - Loaded env from /codebuild/output/src217768232/src/fox/apps/fox/.env
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Checking validity of types...
info - Creating an optimized production build...
info - Using external babel configuration from /codebuild/output/src217768232/src/fox/apps/fox/babel.config.js
at makeError (/root/./-alpha.7/node_modules/execa/lib/error.js:60:11)
at handlePromise (/root/./-alpha.7/node_modules/execa/index.js:118:26)
at runMicrotasks (<anonymous>)
at processTicksAndRejections (internal/process/task_queues.js:95:5)
at async Builder.build (/root/./-alpha.7/node_modules/@sls-next/lambda-at-edge/dist/build.js:421:17)
at async NextjsComponent.build (/root/./-alpha.7/node_modules/@sls-next/-component/dist/component.js:170:13)
at async NextjsComponent.default (/root/./-alpha.7/node_modules/@sls-next/-component/dist/component.js:22:13)
at async fn (/root/.npm/_npx/3432/lib/node_modules//node_modules/@/template/utils.js:280:41)
at async Promise.all (index 0)
at async executeGraph (/root/.npm/_npx/3432/lib/node_modules//node_modules/@/template/utils.js:294:3)
at async Template.default (/root/.npm/_npx/3432/lib/node_modules//node_modules/@/template/.js:67:38)
at async Object.runComponents (/root/.npm/_npx/3432/lib/node_modules//node_modules/@/cli/src/index.js:222:17) {
shortMessage: 'Command failed with exit code 1: node_modules/.bin/next build',
command: 'node_modules/.bin/next build',
escapedCommand: '"node_modules/.bin/next" build',
exitCode: 1,
signal: undefined,
signalDescription: undefined,
stdout: 'info - Loaded env from /codebuild/output/src217768232/src/fox/apps/fox/.env\n' +
'info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5\n' +
'info - Checking validity of types...\n' +
'info - Creating an optimized production build...\n' +
'info - Using external babel configuration from /codebuild/output/src217768232/src/fox/apps/fox/babel.config.js',
stderr: 'warn - You have enabled experimental feature(s).\n' +
'warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.\n' +
'\n' +
'(node:3559) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API\n' +
'(Use `node --trace-deprecation ...` to show where the warning was created)\n' +
'(node:3559) [DEP_WEBPACK_CHUNK_ADD_MODULE] DeprecationWarning: Chunk.addModule: Use new ChunkGraph API\n' +
'Failed to compile.\n' +
'\n' +
'../../node_modules/next/dist/compiled/@vercel/nft/LICENSE\n' +
'Module parse failed: Unexpected token (1:10)\n' +
'You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders\n' +
'> Copyright 2019 Vercel, Inc.\n' +
'| \n' +
'| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:\n' +
'\n' +
'\n' +
'> Build error occurred\n' +
'Error: > Build failed because of webpack errors\n' +
' at /codebuild/output/src217768232/src/fox/node_modules/next/dist/build/index.js:397:19\n' +
' at async Span.traceAsyncFn (/codebuild/output/src217768232/src/fox/node_modules/next/dist/telemetry/trace/trace.js:60:20)\n' +
' at async Object.build [as default] (/codebuild/output/src217768232/src/fox/node_modules/next/dist/build/index.js:77:25)',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
[G
2022-02-08T23:01:48.577Z [ERROR]: [?25h[G[J
164s › d30o3wao502f5x › Error: Command failed with exit code 1: node_modules/.bin/next build
warn - You have enabled experimental feature(s).
warn - Experimental features are not covered by semver, and may cause unexpected or broken application behavior. Use them at your own risk.
(node:3559) [DEP_WEBPACK_CHUNK_HAS_ENTRY_MODULE] DeprecationWarning: Chunk.hasEntryModule: Use new ChunkGraph API
(Use `node --trace-deprecation ...` to show where the warning was created)
(node:3559) [DEP_WEBPACK_CHUNK_ADD_MODULE] DeprecationWarning: Chunk.addModule: Use new ChunkGraph API
Failed to compile.
../../node_modules/next/dist/compiled/@vercel/nft/LICENSE
Module parse failed: Unexpected token (1:10)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> Copyright 2019 Vercel, Inc.
|
| Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
> Build error occurred
Error: > Build failed because of webpack errors
at /codebuild/output/src217768232/src/fox/node_modules/next/dist/build/index.js:397:19
at async Span.traceAsyncFn (/codebuild/output/src217768232/src/fox/node_modules/next/dist/telemetry/trace/trace.js:60:20)
at async Object.build [as default] (/codebuild/output/src217768232/src/fox/node_modules/next/dist/build/index.js:77:25)
info - Loaded env from /codebuild/output/src217768232/src/fox/apps/fox/.env
info - Using webpack 5. Reason: Enabled by default https://nextjs.org/docs/messages/webpack5
info - Checking validity of types...
info - Creating an optimized production build...
info - Using external babel configuration from /codebuild/output/src217768232/src/fox/apps/fox/babel.config.js
[G[?25h
Terminating logging...
This is still not resolved with Amplify NextJS 12 deployment
Please see https://github.com/vercel/next.js/issues/31555#issuecomment-1014870229
You should take this up with the Amplify team. Make sure you check these issues before opening a new one: https://github.com/aws-amplify/amplify-js/labels/Next.js
What version of Next.js are you using?
12.0.5 (Tested from 12.0.1 to 12.0.5 & canary versions)
What version of Node.js are you using?
v16.2.0 (Used > 12.2 as well when searching for the bug)
What browser are you using?
Chrome
What operating system are you using?
Ubuntu 20
How are you deploying your application?
AWS Amplify | Custom Amplify build script that utilizes NX npm package for building.
Describe the Bug
For the last 20 days or so I've been stuck trying to deploy my application to AWS Amplify. I've contacted the AWS support team, spoken to members of the Amplify discord, and haven't found a solution to this issue.
The issue revolves around NextJs build command. Every time the errors vary but the issue always boils down to SWC. So I recently converted my application to a monorepo to split my news app, main and future apps. The repo was built with https://nx.dev/ and it's a fairly basic structure.
The problem seems to be whenever I deploy the application to Amplify, it builds the pages with no problem, it installs everything with no problem, although after it builds it gets a bit tricky. As far as I've been able to determine, you need to have node_moduels in the app root along with the .next folder to get everything to work. My current solution or at least what has gotten me close is this build configuration:
This structure should technically work, I found another user who used this cp approach for his project and it worked. However in my case, it keeps complaining about SWC most often. The error it throws often looks like this failing on Next Build. Before I did the whole copy files thing I used to just install the npm packages in the apps folder although that just caused issues such as
ENOENT node_modules/.bin/next build
Expected Behavior
A normal build should deploy like this, and before I switched to a monorepo I used Next 12 the day it came out and it compiled fine for a single app.
To Reproduce
Here are the related GitHub issues I've commented on or opened that revolve around this build/deployment issue. Amplify Working Build (Should've worked) https://github.com/bmvantunes/aws-amplify-deploy-test-nx/issues/1#issuecomment-970886347 This worked for a moment although styled-components caused issues saying the CSS prop wasn't valid.
Amplify Support Case https://github.com/aws-amplify/amplify-console/issues/2377#issuecomment-968130246 I opened a case with the AWS team and this repo will be where it continues
NX Issue about Amplify https://github.com/nrwl/nx/issues/6172#issuecomment-966675753
Amplify deployment and SWC build issue (Methods for building do not work) https://github.com/aws-amplify/amplify-console/issues/1866#issuecomment-965795422 estyh solved this issue by using a serverless config but it's not ideal. serverless-nextjs/serverless-next.js#1845
To Reproduce
I can't make my repo public but I can specify all the major things that you need.
Package Json Located in root. (It's big, I plan to slim it down)
TS Config Base Located in the root of the project, created by NX.
NX Config Located in the root of the project. Created by NX.
The following config files will be of my News app. The main app is exactly like the news app.
NextJS Config I had transpile node_moduels originally although I switch to YARN so I wouldn't have to go through that BS and I could just use the resolution option.
Package Json of App It's really basic and I don't use it. It exists to tell Amplify to set up the project as NextJS SSR.
Babel SWC styled components in canary isn't ready and it didn't work well so I'm sticking to babel.
build/deployment