serverless-next.js: Cannot find module '@sls-next/next-aws-cloudfront' with serverless-next.js@1.14.0
Describe 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'
]
}
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 1
- Comments: 21 (8 by maintainers)
That’s great news.
For other people landing on this issue, TL;DR is:
If you want to use the
nameinput, 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
nameinput 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-edgethat isn’t compatible with the packageserverless-next.js. This isn’t an issue with@sls-next/serverless-componentbecause 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 👍@danielcondemarin
Yes with
@sls-next/serverless-component@1.15.1and withoutnameit worked.I suspect this issue would happen for any users that had set the
nameinput which wasn’t actually working before this PR was merged.Now that it is working, then the
aws-lambdacomponent will try deleting the lambdas that were previously created using an autogenerated name and create new ones with thenamedefined via the input.That’s my theory anyway, let’s confirm it first.
I have not tried to remove the name as the configuration was the same for while we are using 1.13.0 version.
I will try and let you know.
Thanks @danielcondemarin this is effectively working for us with
1.15.1and as far as we’re not yet in production that’s easy to change.Hopefully you’ll be able to find out what’s the problem for the older versions.
🤞
I’ve just tested and using,
works fine for me. Note the package name change now under an org
@sls-next/Although I’ll try to get to the bottom of the problem please try updating to the latest stable published:
There shouldn’t be breaking changes.