-
Notifications
You must be signed in to change notification settings - Fork 417
Unable to import module 'handler': Error revisited #230
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Hi @two7sclash . Thanks for submitting the issue and the very detailed information 👍 . After a very quick check of the configuration you posted I see nothing obvious at the first sight that could cause the problem. Can you try to do a |
@HyperBrain added the stack trace from CloudWatch logs. |
@HyperBrain inside the package I see: handler.js, node_modules, package-lock.json, package.json. Inside the handler file, I see |
Ok. That helps. There is a dependency missing in the package: There is currently a bug #223 that you hit here. With version
Sorry for the inconvenience. I will try to implement a bugfix for #223 as soon as possible. |
now in
New stack trace is:
|
I'm working on a bugfix for #223 right now. Please be patient - should be available soon |
Just finished the implementation. Needs some local tests. Then I'll prepare a PR that you can test with. |
Looks good so far. However I have to check for any edge cases -> as soon as these work I'll publish the PR. |
@two7sclash Can you try with the plugin version from #231 with the initial project setup and report if it solves the problem? |
@HyperBrain sorry wasn't being impatient, was just trying with I pulled down your PR and, same error as when I use the work around:
So the "request" issue is resolved methinks? This error seems to imply that webpack isn't handling the native |
No problem 😄 , I think the peer dependency issue is then resolved with the PR as You could be right, that the issue has something to do with the handling of the native url module. Which Node version do you use locally? Maybe the Node version used locally and on AWS Lambda are different, so that the compiled code breaks online - just a guess. |
According to the AWS docs:
Can you try to use Node 6.10.3 locally so that it exactly reflects the AWS runtime? |
yeah, I'm already using 6.10.3 locally :/ no problems using |
Just checked the callstack again: It seems that the |
Just cleared the flags as the peer dependency require is solved by #231 . |
taking a look this AM, more soon. |
problem was that the url module was choking on |
I am getting roughly the same error and it happens if I have any require statement at all. |
@stevenmwade Could you elaborate on this a bit more and post a code sample (configs)? |
@HyperBrain I'm getting this issue and have tried all the obvious fixes. I'm on v3.1.2. Is there any more stable version I should switch to? ** this issue only cropped up when I switched to using the |
Can you post the function definitions and the webpackIncludeModules part of your serverless.yml and your webpack.conf.js? If you do not set webpackIncludeModules at all, there will be NO module packaging. 3.1.2 is stable, and there are currently no known issues in that area. It should be merely a configuration issue, but we can find that out by looking at the files. |
Oh man you must get tired of this. I had added the banner plugin for sourcemaps and that was not a dependency that was included in the build, but present in my local... Sorry for that @HyperBrain
feel free to mark my issue as resolved. |
Hey @btburton42 , even if some issues turn out to be a missing configuration, it is quite helpful to have them documented here in the GitHub issues. This will help others who run into the same to have a variety of possible things to check 👍 . However a Wiki might be better to collect them and extract them as Problem->Solution pairs from the issues. As I'm not very used in how to setup a good wiki in GitHub, I could need some help there 😄 . |
I wish to add my name to the list of folks struggling with this issue. It runs fine locally, but gives this error after deploying to AWS. All of the source is here: https://github.com/RALifeCoach/lb-data-engine.git. The actual error is:
|
Hi @RALifeCoach , thanks for the post. I will check the source. It looks like there is something wrong with the webpack configuration (so that it did not bundle/reference a module correctly). What I saw on the first sight is this: plugins:
- serverless-offline
- serverless-webpack You have to revert the order - to make offline work correctly, webpack has to be listed before offline, because that detemines the order of execution (see also the README). I'll let you know if I found something. |
Thanks for looking at this so quickly. I appreciate your time in this matter. I have reversed the order of the plug-ins. However, the error is still happening. |
@RALifeCoach I already have an idea, why. You should use the entry auto-resolution with I can try to submit a PR for your repo tomorrow if that's ok for you. |
Thanks, I will try that and report back to you.
…On Wed, Nov 15, 2017 at 6:17 AM, Frank Schmid ***@***.***> wrote:
@RALifeCoach <https://github.com/ralifecoach> I already have an idea,
why. You should use the entry auto-resolution with slsw.lib.entries (for
details see the README) and set the outputname then to [name].js.
I can try to submit a PR for your repo tomorrow if that's ok for you.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#230 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADrayP-MuQX-cXaBN_PwEfx1sNMWfXhHks5s2h-DgaJpZM4Pc9Wx>
.
--
Christopher Oliphant
+1 647 972 4549
|
I made those 2 changes to the webpack.config.js. I am still getting an error. However, it is nice to know I am moving forward and clearing up the obvious problems of one who fails to read the documentation carefully enough. |
Can you post the current webpack.config? ... and the error (if it is different than before) 😄 |
My changes to webpack config and serverless.yml have been pushed.
…On Wed, Nov 15, 2017 at 6:31 AM, Frank Schmid ***@***.***> wrote:
Can you post the current webpack.config?
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#230 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADrayH8iYpIU94QqK41oj2XIQdcgGcJnks5s2iK5gaJpZM4Pc9Wx>
.
--
Christopher Oliphant
+1 647 972 4549
|
Thanks |
@RALifeCoach I think I found your remaining problem. Just checked out the repo and tried. The external modules were not packaged - the ones detected by node-externals. # serverless.yml
custom:
webpackIncludeModules: true Then the output should be functional. |
That fixed it. You are wonderful. Thank-you.
…On Wed, Nov 15, 2017 at 7:28 AM, Frank Schmid ***@***.***> wrote:
@RALifeCoach <https://github.com/ralifecoach> I think I found your
remaining problem. Just checked out the repo and tried. The external
modules were not packaged - the ones detected by node-externals.
The solution is to enable the plugin's external module packaging:
custom:
webpackIncludeModules: true
Then the output should be functional.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#230 (comment)>,
or mute the thread
<https://github.com/notifications/unsubscribe-auth/ADrayNwXABxPucMkmcXJN1JMgxE7O-b5ks5s2jAqgaJpZM4Pc9Wx>
.
--
Christopher Oliphant
+1 647 972 4549
|
@RALifeCoach You're welcome |
I apologize for resurrecting this issue, but I'm facing (what looks to be) the same thing. I'm using serverless aws with webpack and typescript. It was working just a few days ago, and I'm not sure what I changed that caused this to happen. Everything works find locally. webpack.confi.js
serverless.yml (snippet)
structure:
Please let me know what other information I can provide. Cheers, |
@jkruse14: To debug this, do a I suppose you can try extracting the zip-archive and do a |
Thanks @martinjlowm! I had two modules which I must not have installed with the --save recently. I added those and everything is working - thanks for your help! |
I had this same issue and the only way to fix it was changing to node v6 (via nvm) to compile. |
Hi I need a help, Am new to this node.js and aws lambda, i am just trying a simple way to list out the S3 objects, but am getting the exception as given below Unable to import module 'index': Error Can someone help me on this. If i edit the working aws template then also i receive same error. Unable to understand. |
Duplicate of #43 (comment) |
Same issue |
Just FWIW... I've also been fighting this issues for some hours (which appeared after adding babel to my build chain btw.). Earlier I had the following in my Lambda handler:
Adding babel to webpack and the code above stopped working, Changing the handler method signature to |
fixed my problem, thanks so much. |
This is a Bug Report
Description
For bug reports:
I get
Unable to import module 'handler': Error
when visiting my AWS endpointEverything works fine locally. Expecting same results.
serverless.yml:
webpack.config.js
package.json
then:
curl https://xxx.execute-api.us-east-1.amazonaws.com/dev/alerts
gives{"message": "Internal server error"}
Stack trace is:
Similar or dependent issue(s):
*#43
Additional Data
The text was updated successfully, but these errors were encountered: