Cannot find module '@sls-next/next-aws-cloudfront' with serverless-next.js@1.14.0
See original GitHub issueDescribe the bug
Since this morning, we’re not able to deploy our application due to a missing module Cannot find module '@sls-next/next-aws-cloudfront'
We’ve faced this problem in the past and fixed like described here: https://github.com/serverless-nextjs/serverless-next.js/issues/480#issuecomment-652450945 This has worked for some time but today we’re back to the same issue.
As I understand there is another package available prefixed with @sls-next : https://github.com/serverless-nextjs/serverless-next.js/issues/480#issuecomment-657196903 but this is only from version 1.15.x
as I understand but we’re currently using 1.14.0
To Reproduce
Here is the serverless.yml
configuration that we’re using:
site:
component: serverless-next.js@1.14.0
inputs:
# environment variable syntax is coming from serverless components v1.x
# see the correct documentation here: https://github.com/serverless/components/tree/v1#environment-variables
bucketName: ${env.DEPLOYMENT_BUCKET}
AccelerateConfiguration:
AccelerationStatus: Enabled
Screenshots
aNA
39s › site › Deploying
aNA
error:
Error: Cannot find module '@sls-next/next-aws-cloudfront'
Require stack:
- /root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js
- /root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/index.js
- /root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/serverless-next.js/serverless.js
- /usr/src/app/node_modules/@serverless/core/src/Component.js
- /usr/src/app/node_modules/@serverless/core/src/index.js
- /usr/src/app/node_modules/@serverless/cli/src/index.js
- /usr/src/app/node_modules/serverless/lib/components-v1.js
- /usr/src/app/node_modules/serverless/bin/serverless.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.resolve (internal/modules/cjs/helpers.js:78:19)
at Builder.<anonymous> (/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js:119:49)
at Generator.next (<anonymous>)
at /root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js:8:71
at new Promise (<anonymous>)
at __awaiter (/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js:4:12)
at Builder.buildDefaultLambda (/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js:98:16)
at Builder.<anonymous> (/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js:266:24)
at Generator.next (<anonymous>) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/build.js',
'/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/@sls-next/lambda-at-edge/dist/index.js',
'/root/.serverless/components/registry/npm/serverless-next.js@1.14.0/node_modules/serverless-next.js/serverless.js',
'/usr/src/app/node_modules/@serverless/core/src/Component.js',
'/usr/src/app/node_modules/@serverless/core/src/index.js',
'/usr/src/app/node_modules/@serverless/cli/src/index.js',
'/usr/src/app/node_modules/serverless/lib/components-v1.js',
'/usr/src/app/node_modules/serverless/bin/serverless.js'
]
}
Issue Analytics
- State:
- Created 3 years ago
- Reactions:1
- Comments:21 (8 by maintainers)
Top Results From Across the Web
"Error: Cannot find module '@sls-next/next-aws-cloudfront ...
When either local or in Github actions our serverless command now always fails when deploying with the error: Error: Cannot find module ......
Read more >Serverless Framework with AWS Lambda error "Cannot find ...
I'm trying to use the Serverless Framework to create a Lambda function that uses open weather NPM module. However ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
That’s great news.
For other people landing on this issue, TL;DR is:
If you want to use the
name
input, you’ll need to let serverless-next.js create a new CloudFront distribution. This is an unfortunate consequence of the limitations around deleting lambda@edge functions.Otherwise remove the
name
input and you should be able to continue using@sls-next/serverless-component
.Unfortunately there was a breaking change introduced here accidentally. I suspect serverless is picking a version of
@sls-next/lambda-at-edge
that isn’t compatible with the packageserverless-next.js
. This isn’t an issue with@sls-next/serverless-component
because its up to date.Like I said earlier I don’t expect any breaking changes when using
@sls-next/serverless-component@1.15.1
. If anyone comes across this issue please try updating to that. If after updating it doesn’t work then feel free to open a new issue 👍