serverless-next.js
serverless-next.js copied to clipboard
Serverless Components CLI v1 is no longer bundled with Serverless Framework CLI
Issue Summary
When i try to deploy an app then i receive the next message:
Serverless Components CLI v1 is no longer bundled with Serverless Framework CLI
and the app is not deployed
Actual behavior
The process end with that message
Expected behavior
Tha app is deployed
Steps to reproduce
Try to deploy a app with @sls-next/[email protected]
Screenshots/Code/Configuration/Logs

Versions
- OS/Environment: Ubuntu
- @sls-next/serverless-component version: 3.7.0-alpha.7
- Next.js version: 12
Additional context
Checklist
- [x] You have reviewed the README and FAQs, which answers several common questions.
- [x] You have reviewed our DEBUGGING wiki and have tried your best to include complete information and reproduction steps (including your configuration) as is possible. As there is only one maintainer (who maintains this in his free time) and thus very limited resources, if you have time, please try to debug the issue a bit yourself if possible.
- [ ] You have first tried using the most recent
latestoralpha@sls-next/serverless-componentrelease version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the oldserverless-next.jscomponent and theserverless-next.jsplugin are deprecated and no longer maintained.
Hm, seems some others faced this too, I think you could pin to an older version of [email protected] when deploying which will have the old beta serverless components in it and it should work?
@dphang i tried with a older version but i have the same problem
Serverless released a new version today and i think that the new version break the workflow because it separate the Component CLI from the Serverless Framework CLI
@ferdingler Thanks, that work for now.
Glad that I looked at recent issues created on the Repo. Thanks @ferdingler
Same issue here!
Is there a long term solution for this? Has anyone tried the recommendation in the serverless message? I wasn't sure what to put for <command> and <options>
Same here:
Serverless Components CLI v1 is no longer bundled with Serverless Framework CLI
It asks to do this:
To run it, ensure it's installed:
npm install -g @serverless/cli
Then run:
components-v1 <command> <options>
When I try to use npx serverless
How @ferdingler says, we have to specify the serverless version in the console, specifically a version before of 3.0.
We have to await for someone of the contributors release a new version or somebody is free to submit a pull request with a modification in the serverless version while the integrations with serverless@3 is ready
I got the same problem. I ran components-v1 and it started deploying, until it failed with a rather verbose output:
error:
Error: Command failed with exit code 1: node_modules/.bin/next build
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
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:
Import trace for requested module:
./node_modules/next/dist/compiled/@vercel/nft/ sync ^\.\/.*$
./node_modules/next/dist/compiled/@vercel/nft/index.js
./node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
./node_modules/next/dist/build/webpack-config.js
./node_modules/next/dist/server/dev/hot-reloader.js
./node_modules/next/dist/server/dev/next-dev-server.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
./node_modules/next/dist/compiled/webpack/bundle5.js:141344:0
Module not found: Can't resolve 'next/dist/build/webpack/plugins/terser-webpack-plugin'
Import trace for requested module:
./node_modules/next/dist/compiled/webpack/webpack.js
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
./node_modules/next/dist/compiled/webpack/webpack.js:9:0
Module not found: Can't resolve 'webpack5/lib/javascript/BasicEvaluatedExpression'
Import trace for requested module:
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
./node_modules/next/dist/compiled/webpack/webpack.js:11:0
Module not found: Can't resolve 'webpack5/lib/ModuleFilenameHelpers'
Import trace for requested module:
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
./node_modules/next/dist/compiled/webpack/webpack.js:13:0
Module not found: Can't resolve 'webpack5/lib/node/NodeTargetPlugin'
Import trace for requested module:
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
> Build failed because of webpack errors
info - Loaded env from /Users/janklan/dev/website/.env.local
info - Loaded env from /Users/janklan/dev/website/.env
info - Checking validity of types...
info - Creating an optimized production build...
at makeError (/Users/janklan/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/execa/lib/error.js:60:11)
at handlePromise (/Users/janklan/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/execa/index.js:118:26)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async Builder.build (/Users/janklan/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/lambda-at-edge/dist/build.js:421:17)
at async NextjsComponent.build (/Users/janklan/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/serverless-component/dist/component.js:170:13)
at async NextjsComponent.default (/Users/janklan/.serverless/components/registry/npm/@sls-next/[email protected]/node_modules/@sls-next/serverless-component/dist/component.js:22:13)
at async fn (/Users/janklan/.nvm/versions/node/v16.13.1/lib/node_modules/@serverless/cli/node_modules/@serverless/template/utils.js:280:41)
at async Promise.all (index 0)
at async executeGraph (/Users/janklan/.nvm/versions/node/v16.13.1/lib/node_modules/@serverless/cli/node_modules/@serverless/template/utils.js:294:3)
at async Template.default (/Users/janklan/.nvm/versions/node/v16.13.1/lib/node_modules/@serverless/cli/node_modules/@serverless/template/serverless.js:67:38) {
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 /Users/janklan/dev/website/.env.local\n' +
'info - Loaded env from /Users/janklan/dev/website/.env\n' +
'info - Checking validity of types...\n' +
'info - Creating an optimized production build...',
stderr: 'warn - The `target` config is deprecated and will be removed in a future version.\n' +
'See more info here https://nextjs.org/docs/messages/deprecated-target-config\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' +
'Import trace for requested module:\n' +
'./node_modules/next/dist/compiled/@vercel/nft/ sync ^\\.\\/.*$\n' +
'./node_modules/next/dist/compiled/@vercel/nft/index.js\n' +
'./node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js\n' +
'./node_modules/next/dist/build/webpack-config.js\n' +
'./node_modules/next/dist/server/dev/hot-reloader.js\n' +
'./node_modules/next/dist/server/dev/next-dev-server.js\n' +
'./node_modules/next/dist/server/next.js\n' +
'./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js\n' +
'./node_modules/@sentry/nextjs/dist/index.server.js\n' +
'./sentry.server.config.js\n' +
'\n' +
'./node_modules/next/dist/compiled/webpack/bundle5.js:141344:0\n' +
"Module not found: Can't resolve 'next/dist/build/webpack/plugins/terser-webpack-plugin'\n" +
'\n' +
'Import trace for requested module:\n' +
'./node_modules/next/dist/compiled/webpack/webpack.js\n' +
'./node_modules/next/dist/server/config-utils.js\n' +
'./node_modules/next/dist/server/config.js\n' +
'./node_modules/next/dist/server/next.js\n' +
'./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js\n' +
'./node_modules/@sentry/nextjs/dist/index.server.js\n' +
'./sentry.server.config.js\n' +
'\n' +
'https://nextjs.org/docs/messages/module-not-found\n' +
'\n' +
'./node_modules/next/dist/compiled/webpack/webpack.js:9:0\n' +
"Module not found: Can't resolve 'webpack5/lib/javascript/BasicEvaluatedExpression'\n" +
'\n' +
'Import trace for requested module:\n' +
'./node_modules/next/dist/server/config-utils.js\n' +
'./node_modules/next/dist/server/config.js\n' +
'./node_modules/next/dist/server/next.js\n' +
'./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js\n' +
'./node_modules/@sentry/nextjs/dist/index.server.js\n' +
'./sentry.server.config.js\n' +
'\n' +
'https://nextjs.org/docs/messages/module-not-found\n' +
'\n' +
'./node_modules/next/dist/compiled/webpack/webpack.js:11:0\n' +
"Module not found: Can't resolve 'webpack5/lib/ModuleFilenameHelpers'\n" +
'\n' +
'Import trace for requested module:\n' +
'./node_modules/next/dist/server/config-utils.js\n' +
'./node_modules/next/dist/server/config.js\n' +
'./node_modules/next/dist/server/next.js\n' +
'./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js\n' +
'./node_modules/@sentry/nextjs/dist/index.server.js\n' +
'./sentry.server.config.js\n' +
'\n' +
'https://nextjs.org/docs/messages/module-not-found\n' +
'\n' +
'./node_modules/next/dist/compiled/webpack/webpack.js:13:0\n' +
"Module not found: Can't resolve 'webpack5/lib/node/NodeTargetPlugin'\n" +
'\n' +
'Import trace for requested module:\n' +
'./node_modules/next/dist/server/config-utils.js\n' +
'./node_modules/next/dist/server/config.js\n' +
'./node_modules/next/dist/server/next.js\n' +
'./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js\n' +
'./node_modules/@sentry/nextjs/dist/index.server.js\n' +
'./sentry.server.config.js\n' +
'\n' +
'https://nextjs.org/docs/messages/module-not-found\n' +
'\n' +
'\n' +
'> Build failed because of webpack errors',
failed: true,
timedOut: false,
isCanceled: false,
killed: false
}
32s › app › Error: Command failed with exit code 1: node_modules/.bin/next build
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
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:
Import trace for requested module:
./node_modules/next/dist/compiled/@vercel/nft/ sync ^\.\/.*$
./node_modules/next/dist/compiled/@vercel/nft/index.js
./node_modules/next/dist/build/webpack/plugins/next-trace-entrypoints-plugin.js
./node_modules/next/dist/build/webpack-config.js
./node_modules/next/dist/server/dev/hot-reloader.js
./node_modules/next/dist/server/dev/next-dev-server.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
./node_modules/next/dist/compiled/webpack/bundle5.js:141344:0
Module not found: Can't resolve 'next/dist/build/webpack/plugins/terser-webpack-plugin'
Import trace for requested module:
./node_modules/next/dist/compiled/webpack/webpack.js
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
./node_modules/next/dist/compiled/webpack/webpack.js:9:0
Module not found: Can't resolve 'webpack5/lib/javascript/BasicEvaluatedExpression'
Import trace for requested module:
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
./node_modules/next/dist/compiled/webpack/webpack.js:11:0
Module not found: Can't resolve 'webpack5/lib/ModuleFilenameHelpers'
Import trace for requested module:
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
./node_modules/next/dist/compiled/webpack/webpack.js:13:0
Module not found: Can't resolve 'webpack5/lib/node/NodeTargetPlugin'
Import trace for requested module:
./node_modules/next/dist/server/config-utils.js
./node_modules/next/dist/server/config.js
./node_modules/next/dist/server/next.js
./node_modules/@sentry/nextjs/dist/utils/instrumentServer.js
./node_modules/@sentry/nextjs/dist/index.server.js
./sentry.server.config.js
https://nextjs.org/docs/messages/module-not-found
> Build failed because of webpack errors
info - Loaded env from /Users/janklan/dev/website/.env.local
info - Loaded env from /Users/janklan/dev/website/.env
info - Checking validity of types...
info - Creating an optimized production build...
Running node_modules/.bin/next build manually builds the app with no errors.
I'm not sure if/how is all this relevant, but I do hope it helps!
As a temporary fix, I just installed serverless locally on a version older than 3.0.0 which has breaking changes. And apparently things started working again...
serverless -v
Framework Core: 2.72.1
Plugin: 5.5.4
SDK: 4.3.1
Components: 3.18.2
I have this same issue, is there a resolution to this?
Same here
So the main serverless repo upgraded to v3 with breaking changes, there is a blog post on it. I had the deployment as part of my ci flow and changed npm install -g serverless to npm install -g [email protected] and then my other commands worked as before. Temporary fix for the moment
Now I have this issue, any idea why?

So is Serverless versions >=3 messed up for Next deployments? I use Aws Amplify to deploy and I hijack the serverless config with my own, it seems that deploying a Next app with just Next as a dependency works fine, however, if you start adding things like Sentry, Next/MDX then it throws the vercel/NFT/license error and fails to build. Is the current solution to use 2.72.2?
So is Serverless versions >=3 messed up for Next deployments? I use Aws Amplify to deploy and I hijack the serverless config with my own, it seems that deploying a Next app with just Next as a dependency works fine, however, if you start adding things like Sentry, Next/MDX then it throws the vercel/NFT/license error and fails to build. Is the current solution to use
2.72.2?
@Rafcin Yes, currently the unique workaround is install [email protected] as a dev dependecy
I'm just modified my config to use 2.72.2 so I'll see if it builds, I wonder if this has been the issue the whole time! I could never deploy with 12 and I always thought something with Next v >=12 or some of those packages caused these issues.
Now that AWS has cutoff support for the aws:states:opt-out workaround, and only serverless versions >= 3.5.3 work with lambda states per here https://github.com/serverless-nextjs/serverless-next.js/issues/1976 , is anyone else completely hosed on next serverless in AWS lambda too?
We fixed the lambda states issue by upgrading Serverless Next from 1.18 to 3.6.0 in the serverless.yml file.
We fixed the lambda states issue by upgrading Serverless Next from 1.18 to 3.6.0 in the serverless.yml file.
Thank you a ton for this @uclaeamsavino , this workaround is also functioning for us now.
I have the same issue and below commands worked for me, as recommended.
npm install -g [email protected]
serverless --version
serverless --debug
Soluction:
- npm install global serverless version 2.7.2
npm install -g [email protected]
sls -v

- In the package.json
"dependencies": {
"@sls-next/aws-cloudfront": "3.6.0",
"@sls-next/aws-lambda": "3.6.0",
"@sls-next/aws-sqs": "^3.5.3",
"@sls-next/domain": "^3.5.3",
"@sls-next/serverless-component": "3.6.0",
...
}
- In the file serveless.yml
next-new :
component : "./node_modules/@sls-next/serverless-component"
- Results 5.1 deploy for aws
sls

sls --debug

5.2 remove for aws
sls remove

@janklan have you solved your issue with sentry and serverless? i'm having this too
When is this expected to be fixed? I've been using the workarounds here for some time but when my app gets more mature and with new requirements I hit new problems..
Is it an issue of Serverless of the Next component? Because according to the Serverless Components README npm i -g serverless should be enough to use the serverless CLI.
Also, installing the CLI locally and using the components-v1 command does not allow passing any arguments to it, lakes documentation and overall feels weird and hacky.
Again, not sure where is the problem, whereever it is, if it's a bug I totally get it, but if it's a result of an intended separation of the framework from the CLI as I understand from the error message then IMHO it wasn't thought thoroughly and should be rolled back and done in an "API first" approach.
Thanks for all the hard work everyone is putting in it!
Install the cli using, npm install -g @serverless/cli and then run components-v1
I'm also wondering what the path forward here would be? Would be nice if one of the maintainers could shed some more light on how to handle the versioning and what the plan for the future is. from what i understand is that this package will basically never support the new components apis?
my way to go was the following:
npm i [email protected] --save-dev
npm i @sls-next/serverless-component --save-dev
someProject:
component: "./node_modules/@sls-next/serverless-component"
"scripts": {
"deploy": "./node_modules/.bin/serverless"
}
@martinjuhasz thanks for sharing. I couldn't get anything to work. What is missing to be able to run serverless 3?
omg..

What the hell is wrong with you?