serverless-next.js icon indicating copy to clipboard operation
serverless-next.js copied to clipboard

Command failed with exit code 1: node_modules/.bin/next build

Open MakdiaHussain opened this issue 2 years ago • 7 comments

I have made a few frontend changes to the project and was trying to deploy my code as usual using the npx serverless command but it fails with the following error. My node version: v14.17.0 and npm version: 6.14.6

13s » ireadifyweb » Error: Command failed with exit code 1: node_modules/.bin/next build warn - Invalid next.config.js options detected:

  • The root value has an unexpected property, target, which is not in the list of allowed properties (amp, analyticsId, assetPrefix, basePath, cleanDistDir, compiler, compress, crossOrigin, devIndicators, distDir, env, eslint, excludeDefaultMomentLocales, experimental, exportPathMap, future, generateBuildId, generateEtags, headers, httpAgentOptions, i18n, images, onDemandEntries, optimizeFonts, output, outputFileTracing, pageExtensions, poweredByHeader, productionBrowserSourceMaps, publicRuntimeConfig, reactStrictMode, redirects, rewrites, sassOptions, serverRuntimeConfig, staticPageGenerationTimeout, swcMinify, trailingSlash, typescript, useFileSystemPublicRoutes, webpack).

See more info here: https://nextjs.org/docs/messages/invalid-next-config warn - The target config is deprecated and will be removed in a future version. See more info here https://nextjs.org/docs/messages/deprecated-target-config warn - No ESLint configuration detected. Run next lint to begin setup Failed to compile.

./node_modules/@aws-amplify/graphql-transformer-interfaces/src/index.ts:2:10 Type error: Re-exporting a type when the '--isolatedModules' flag is provided requires using 'export type'.

1 | export * from './transformer-context';

2 | export { TransformerPluginProvider, TransformerPluginType } from './transformer-plugin-provider'; | ^ 3 | export { 4 | MutationFieldType, 5 | QueryFieldType,

Build error occurred Error: Call retries were exceeded at ChildProcessWorker.initialize (D:\ireadify\node_modules\next\dist\compiled\jest-worker\index.js:1:11661) at ChildProcessWorker._onExit (D:\ireadify\node_modules\next\dist\compiled\jest-worker\index.js:1:12599) at ChildProcess.emit (events.js:376:20) at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) { type: 'WorkerError' } info - Linting and checking validity of types... bug

MakdiaHussain avatar Aug 26 '22 10:08 MakdiaHussain

same error

xiaoxiaosaohuo avatar Aug 31 '22 08:08 xiaoxiaosaohuo

Getting this same error as well on AWS Amplify too

anonmily avatar Aug 31 '22 11:08 anonmily

Getting the same error after upgrading to Webpack 5 manually from Webpack 4 (this was in preparation for an upgrade from Next 11 to Next 12). It's a Next.js codebase, but as soon as Webpack was upgraded, Serverless stopped working, so I don't think it's Next that is the issue

dana-ciocan avatar Sep 09 '22 10:09 dana-ciocan

Yep I get this error. There is no target prop in my next.config.js so it's unclear how to fix it.

However, it looks as if another file was causing the issue so I was able to build.

davidrhoderick avatar Sep 09 '22 16:09 davidrhoderick

@davidrhoderick yeah I don't have a target prop in my next.config.js either so in a similar situation.

What was the problem with the other file, out of interest?

dana-ciocan avatar Sep 10 '22 06:09 dana-ciocan

@dana-ciocan it was a very stupid mistake I made: I had a middleware file that it complained about so I just renamed the file to index.js but of course that would fail to render as a page because it outputs JSON and no React component...

It's just annoying that this command failed because of target is shown as the first error so it looks like that's what I have to fix first. This bug should still get addressed even if it doesn't block builds altogether.

davidrhoderick avatar Sep 10 '22 14:09 davidrhoderick

@davidrhoderick thanks for the tip - I had a look at the error displayed after the target warning and found a note about Terser - turns out our version of terser-webpack-plugin was out of date and causing issues

Agree that it's misleading having that warning display first

dana-ciocan avatar Sep 13 '22 12:09 dana-ciocan