Skip to content
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

Handler not found while running the babel example after npm install #253

Closed
cggaurav opened this issue Oct 16, 2017 · 9 comments
Closed
Milestone

Comments

@cggaurav
Copy link

cggaurav commented Oct 16, 2017

☁ babel [master] ⚡ serverless invoke local -f hello

Serverless: Bundling with Webpack...
Time: 1374ms
  Asset    Size  Chunks                    Chunk Names
main.js  311 kB       0  [emitted]  [big]  main
 [158] ./handler.js 748 bytes {0} [built]
 [159] ./node_modules/babel-runtime/core-js/promise.js 88 bytes {0} [built]
 [160] ./node_modules/core-js/library/fn/promise.js 298 bytes {0} [built]
 [194] ./node_modules/babel-polyfill/lib/index.js 833 bytes {0} [built]
 [195] ./node_modules/core-js/shim.js 8.18 kB {0} [built]
 [242] ./node_modules/core-js/modules/es6.math.imul.js 539 bytes {0} [built]
 [383] ./node_modules/core-js/modules/es7.reflect.get-own-metadata-keys.js 364 bytes {0} [built]
 [384] ./node_modules/core-js/modules/es7.reflect.has-metadata.js 677 bytes {0} [built]
 [385] ./node_modules/core-js/modules/es7.reflect.has-own-metadata.js 384 bytes {0} [built]
 [386] ./node_modules/core-js/modules/es7.reflect.metadata.js 498 bytes {0} [built]
 [387] ./node_modules/core-js/modules/es7.asap.js 442 bytes {0} [built]
 [388] ./node_modules/core-js/modules/es7.observable.js 5.51 kB {0} [built]
 [389] ./node_modules/core-js/modules/web.timers.js 771 bytes {0} [built]
 [392] ./node_modules/babel-polyfill/node_modules/regenerator-runtime/runtime.js 24.4 kB {0} [built]
 [393] ./node_modules/core-js/fn/regexp/escape.js 108 bytes {0} [built]
    + 381 hidden modules
{ Error: Cannot find module '/Users/x/serverless-webpack/examples/babel/.webpack/service/handler'
    at Function.Module._resolveFilename (module.js:527:15)
    at Function.Module._load (module.js:476:23)
    at Module.require (module.js:568:17)
    at require (internal/module.js:11:18)
    at AwsInvokeLocal.invokeLocalNodeJs (/x/.nvm/v8.5.0/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:251:33)
    at AwsInvokeLocal.invokeLocal (/x/.nvm/v8.5.0/lib/node_modules/serverless/lib/plugins/aws/invokeLocal/index.js:125:19)
    at AwsInvokeLocal.tryCatcher (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/util.js:16:23)
    at Promise._settlePromiseFromHandler (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:512:31)
    at Promise._settlePromise (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:569:18)
    at Promise._settlePromise0 (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:614:10)
    at Promise._settlePromises (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/promise.js:693:18)
    at Async._drainQueue (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:133:16)
    at Async._drainQueues (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:143:10)
    at Immediate.Async.drainQueues (/x/.nvm/v8.5.0/lib/node_modules/serverless/node_modules/bluebird/js/release/async.js:17:14)
    at runCallback (timers.js:781:20)
    at tryOnImmediate (timers.js:743:5)
    at processImmediate [as _immediateCallback] (timers.js:714:5) code: 'MODULE_NOT_FOUND' }```
@HyperBrain
Copy link
Member

@cggaurav Thanks for the report. It seems that some of the examples are not yet adapted for version 3 of the plugin (especially the output section and the handler definitions in serverless.yml). The stacktrace seems to indicate this issue.
I will have a look and try to get them up to date.

In the meantime, could you try the babel-dynamically example?

@HyperBrain
Copy link
Member

HyperBrain commented Oct 19, 2017

@franciscocpg We should make all examples fully compliant to the dynamic entry resolution so that there are none left using the old fixed entry generation. It would be better to have samples instead, that show the use of some webpack plugins together with the plugin to solve common problems (like the copy file plugin or sourcemaps).
What do you think?

@HyperBrain
Copy link
Member

Related to #250

@HyperBrain
Copy link
Member

Currently reworking and updating the examples in #259

@HyperBrain
Copy link
Member

@cggaurav The examples have been updated properly now. Additionally, I will release [email protected] right now, so you should update.
Imo we can close this issue then?

@pcowgill
Copy link
Contributor

pcowgill commented Feb 3, 2018

@HyperBrain Is there a use case where it's better to use babel over babel-dynamically-entries? I noticed that in this issue and #290 you suggest trying babel-dynamically-entries

@HyperBrain
Copy link
Member

@pcowgill The dynamic entry point resolution is the proposed way to go (babel-dynamically-entries), because only dynamic entry point resolution lets you use Serverless completely. Especially individual packaging, including a per function dependency optimization is only available with that approach.
babel-dynamically-entries is the example for this standard use case.

I just inspected the babel example, and found that it also uses the same mechanism, but makes use of .babelrc instead of defining the loader options in the webpack.config.js. Additionally, it only uses one function.

We should remove that example because it does not add any value compared to the dynamically example.

@pcowgill
Copy link
Contributor

pcowgill commented Feb 6, 2018

@HyperBrain I removed the babel example in #320 and renamed babel-dynamically-entries to babel (since the simpler naming improves the odds people will look at it first).

@HyperBrain HyperBrain added this to the 4.3.0 milestone Feb 6, 2018
@HyperBrain
Copy link
Member

Closed by #320

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants