serverless-next.js: 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/serverless-component@3.7.0-alpha.7

Screenshots/Code/Configuration/Logs

Screen Shot 2022-01-27 at 15 12 12 Screen Shot 2022-01-27 at 15 13 46

Versions

Additional context

Checklist

  • You have reviewed the README and FAQs, which answers several common questions.
  • 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 latest or alpha @sls-next/serverless-component release version, which may have already fixed your issue or implemented the feature you are trying to use. Note that the old serverless-next.js component and the serverless-next.js plugin are deprecated and no longer maintained.

About this issue

  • Original URL
  • State: open
  • Created 2 years ago
  • Reactions: 36
  • Comments: 34

Commits related to this issue

Most upvoted comments

Try this to deploy:

npx serverless@2.72.2

Soluction:

  1. npm install global serverless version 2.7.2
 npm install -g serverless@2.72.2
 sls -v

Captura de Tela 2022-03-23 às 20 26 09

  1. 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",
    ...
}
  1. In the file serveless.yml
next-new :
   component : "./node_modules/@sls-next/serverless-component"
  1. Results 5.1 deploy for aws
sls 

Captura de Tela 2022-03-23 às 20 18 11

sls --debug

Captura de Tela 2022-03-23 às 20 30 33 Captura de Tela 2022-03-23 às 20 28 38

5.2 remove for aws

sls remove

Captura de Tela 2022-03-23 às 20 21 04

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

Install the cli using, npm install -g @serverless/cli and then run components-v1

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/serverless-component@3.7.0-alpha.7/node_modules/execa/lib/error.js:60:11)
    at handlePromise (/Users/janklan/.serverless/components/registry/npm/@sls-next/serverless-component@3.7.0-alpha.7/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/serverless-component@3.7.0-alpha.7/node_modules/@sls-next/lambda-at-edge/dist/build.js:421:17)
    at async NextjsComponent.build (/Users/janklan/.serverless/components/registry/npm/@sls-next/serverless-component@3.7.0-alpha.7/node_modules/@sls-next/serverless-component/dist/component.js:170:13)
    at async NextjsComponent.default (/Users/janklan/.serverless/components/registry/npm/@sls-next/serverless-component@3.7.0-alpha.7/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!

This worked for me:

yarn add -D @serverless/cli

Then every time you want to deploy:

yarn components-v1

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 serverless@2.72.2 and then my other commands worked as before. Temporary fix for the moment

Hey all,

I am sorry for the lack of activity recently…honestly I got busy with other personal interests and was having trouble with finding other long-term maintainers. For fully visibility, Yes currently this library has to use that specific old version of Serverless components since it’s still on the beta components, and there is definitely a lot of tech debt from this (the original maintainer started this library when it was still in beta and it wasn’t upgraded). At a previous time I had looked into it but IIRC the GA components had some major incompatibilities with (I think it was something to do with needing to have custom build or deploy logic which at the time wasn’t compatible with GA components doing builds/deploys in the Serverless cloud?). But it might definitely have changed now since that was a while ago.

Long term we definitely should upgrade, although an equally viable path is to use things like CDK or Terraform CDK to deploy (eg there are solutions like Serverless Stack that are well-funded that use AWS CDK this way - perhaps we can explore more collaboration with them), which we have as deployers for lambda@edge and lambda (more diy), or try to get out of maintaining AWS deploy logic if possible.

There is a budget for Serverless components upgrade ($1000) and more general funds (to the tune of around $1100), so if anyone is seriously interested to work on this, please join the slack (send an email to serverlessnextjs@gmail.com for an invite) and it may be worth your while as there are decent financial incentives which we can work out depending on how much time you want to spend. I currently don’t need the money myself and my time is quite limited these days, so I’m hoping for other core contributors…

there are also other long term things to fix such as how to better keep up with feature parity with Next.js (for example, running Next.js server instead of emulating the routing logic ourselves) so we don’t have constant bugs due to differing behavior. And of course other projects like bringing it to Azure/GCP etc (but I would prefer making this more stable first)

Thanks for reading.

@martinjuhasz thanks for sharing. I couldn’t get anything to work. What is missing to be able to run serverless 3?

Glad that I looked at recent issues created on the Repo. Thanks @ferdingler

Still having the issue: serverless@3.19.0, @serverless/cli@1.6.0 serverless@2.72.3 works for me

omg… image

What the hell is wrong with you?

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 serverless@2.72.2 --save-dev
npm i @sls-next/serverless-component --save-dev
someProject:
  component: "./node_modules/@sls-next/serverless-component"
"scripts": {
    "deploy": "./node_modules/.bin/serverless"
  }

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!

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 serverless@2.72.2 as a dev dependecy

Now I have this issue, any idea why? CleanShot 2022-02-08 at 15 05 08

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

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>

@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