serverless-plugin-warmup: Unable to import module
Hi,
the plugin does not work for me, from CloudWatch Logs:
Unable to import module '_warmup/index': Error at Function.Module._resolveFilename (module.js:469:15) at Function.Module._load (module.js:417:25) at Module.require (module.js:497:17) at require (internal/module.js:20:19)
Unable to import module '_warmup/index': Error
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
Does it only work if you are using nodejs runtime?
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 1
- Comments: 34 (16 by maintainers)
Actually, just created a PR in Serverless that fix the root cause of this issue (the
individuallyconfig is not honored when there is apackage: artifact: ...set up at service level).Let’s see if it can get merge and we won’t need to workaround the issue 🙂
So how did you guys resolve the issue? Even with cleanFolder set false the issue still remains.
If anyone other (next to me) is struggling over this issue and has problems solving it with the above discussion:
Issue
When you install the plugin via npm and you run
sls package, a directory called ‘_warmup’ within your service root will be created. If you now runsls deploy, the (in serverless.yml) specified artifact (package: artifact: artifactpath) will be uploaded to the deploy bucket on aws. But the _warumup dir which consists of the warump function written in javascript is ignored. This causes the “module not found” error in CloudWatchThe solution
You have to move the _warmup dir into your resources folder (src.main.resources) of your service. This folder will be unpacked by maven and will be added to the root of the .jar. AWS will search within this jar for a dir ‘_warmup’ which consists of a index.js.
In commands
All commands are from the root of your service
‘_warmup’ will be created
move the folder to your resources dir
package the artifact
deploys the jar
and here is my serverless.yml conf for the plugin