serverless-next.js: Started getting the Error: Cannot find module '@sls-next/next-aws-cloudfront'
Describe the bug My deployments have been working well on AWS being ran by code build. Today I suddenly got an error for my builds on two separate AWS instances with the error:
{ Error: Cannot find module '@sls-next/next-aws-cloudfront'
--
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15)
at Function.resolve (internal/modules/cjs/helpers.js:33:19)
at Builder.<anonymous> (/root/.serverless/components/registry/npm/serverless-next.js@1.15.0-alpha.2/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.15.0-alpha.2/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.15.0-alpha.2/node_modules/@sls-next/lambda-at-edge/dist/build.js:4:12)
at Builder.buildDefaultLambda (/root/.serverless/components/registry/npm/serverless-next.js@1.15.0-alpha.2/node_modules/@sls-next/lambda-at-edge/dist/build.js:98:16)
at Builder.<anonymous> (/root/.serverless/components/registry/npm/serverless-next.js@1.15.0-alpha.2/node_modules/@sls-next/lambda-at-edge/dist/build.js:266:24)
at Generator.next (<anonymous>) code: 'MODULE_NOT_FOUND' }
·[G·[?25h·[G·[J
64s › myApp › Error: Cannot find module '@sls-next/next-aws-cloudfront'
Expected behaviour Ideally the deployment should give a success and output the cloudfront link.
Additional context I haven’t had any package related issue with the package and I’m running using the following in my package JSON.
"serverless": "^1.67.0",
"serverless-next.js": "^1.9.5",
About this issue
- Original URL
- State: closed
- Created 4 years ago
- Reactions: 10
- Comments: 17 (6 by maintainers)
Hi folks, please pin the version number in your
serverless.ymllike it states in the README. For example:Thank you @danielcondemarin , it worked nicely after deleting existing cloudfront distribution and lambdas.
and my lambdas are named properly now. 🎉🎉🎉
Just be aware 1.9.5 is 5 minor versions behind… Suggest using 1.14.0 or 1.15.0-alpha.1(last known good before breaking changes)
Hi, is there any way of not deleting the existing stack, and solving this issue? I’ve just cloned my repo from a new machine and tried to deploy locally and it failed. (same serverless version and node version)
Here is the stack trace:
One thing that does worry me a bit is that it’s trying to access my global npm modules and searching there instead of using the local npm modules in the repository.
Any ideas on how to solve this?
it worked for me by replacing
to
I don’t know what to put in my serverless.yml. All I have is
component: serverless-next.jsunder myApp, and I don’t seem to have a serverless-next package installed. Also, the instructions on serverless.com say this:How do I find the version of serverless-next that I should pin it to in my serverless.yml?
Thanks it works.
Must be a new config from when I plugged in the package into my project. I followed the docs when they were at this state: https://github.com/serverless-nextjs/serverless-next.js/blob/ed2b3beda852a3ed55789d167cb378cdbe690d53/README.md. Haven’t had a need to look at them since then.