serverless-webpack: invoke local "The webpack plugin could not find the configuration file"
This is a (Bug Report)
Description
serverless invoke local -f <functionName> doesn’t work
For bug reports:
-
What went wrong? A few weird errors occur:
- It says that more than one matching handler is found
- It is looking in the wrong place for the
webpack.config.jsfile which is located at./webpack.config.js
-
What did you expect should have happened?
serverless invoke localshould work in a project that functions correctly withserverless-offline -
What was the config you used?
service: api
package:
individually: true
provider:
name: aws
runtime: provided
stage: "${opt:stage, 'local'}"
region: us-east-1
environment:
DEBUG: '*,-babel,-babel:config:*'
SLS_DEBUG: '*'
functions:
test:
handler: src/jobs/test.handler
layers: # add layer
- arn:aws:lambda:us-east-1:553035198032:layer:nodejs10:13
plugins:
- serverless-webpack
- serverless-offline
custom:
serverless-offline:
host: 0.0.0.0
port: 8080
providedRuntime: nodejs10
webpack:
webpackConfig: 'webpack.config.js'
packager: 'yarn'
includeModules: true
-
What stacktrace or error message from your provider did you see?
The webpack plugin could not find the configuration file at: /Users/user/work/project/api/.webpack/test/webpack.config.js
Similar or dependent issue(s):
Additional Data
- Serverless-Webpack Version you’re using: v5.3.0
- Webpack version you’re using: v4.33.0
- Serverless Framework Version you’re using: v1.44.1
- Operating System: macOS 10.14.5 (18F132)
- Stack Trace (if available):
$ serverless invoke local -f test
Serverless: Invoke webpack:validate
Serverless: Invoke webpack:compile
Serverless: Bundling with Webpack...
Time: 269ms
Built at: 06/05/2019 1:57:53 PM
Asset Size Chunks Chunk Names
src/jobs/test.js 4.07 KiB src/jobs/test [emitted] src/jobs/test
src/jobs/test.js.map 3.86 KiB src/jobs/test [emitted] src/jobs/test
Entrypoint src/jobs/test = src/jobs/test.js src/jobs/test.js.map
[./src/jobs/test.ts] 89 bytes {src/jobs/test} [built]
Serverless: Invoke package
Serverless: Invoke aws:common:validate
Serverless: Invoke aws:common:cleanupTempDir
Serverless: Invoke webpack:validate
Serverless: WARNING: More than one matching handlers found for 'src/jobs/test'. Using 'src/jobs/test.js'.
Serverless Error ---------------------------------------
The webpack plugin could not find the configuration file at: /Users/user/work/project/api/.webpack/test/webpack.config.js
Stack Trace --------------------------------------------
ServerlessError: The webpack plugin could not find the configuration file at: /Users/user/work/project/api/.webpack/test/webpack.config.js
at ServerlessWebpack.validate (/Users/user/work/project/api/node_modules/serverless-webpack/lib/validate.js:111:33)
at ServerlessWebpack.tryCatcher (/Users/user/work/project/api/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/user/work/project/api/node_modules/bluebird/js/release/promise.js:517:31)
at Promise._settlePromise (/Users/user/work/project/api/node_modules/bluebird/js/release/promise.js:574:18)
at Promise._settlePromiseCtx (/Users/user/work/project/api/node_modules/bluebird/js/release/promise.js:611:10)
at _drainQueueStep (/Users/user/work/project/api/node_modules/bluebird/js/release/async.js:142:12)
at _drainQueue (/Users/user/work/project/api/node_modules/bluebird/js/release/async.js:131:9)
at Async._drainQueues (/Users/user/work/project/api/node_modules/bluebird/js/release/async.js:147:5)
at Immediate.Async.drainQueues [as _onImmediate] (/Users/user/work/project/api/node_modules/bluebird/js/release/async.js:17:14)
at runCallback (timers.js:705:18)
at tryOnImmediate (timers.js:676:5)
at processImmediate (timers.js:658:5)
at process.topLevelDomainCallback (domain.js:120:23)
Get Support --------------------------------------------
Docs: docs.serverless.com
Bugs: github.com/serverless/serverless/issues
Issues: forum.serverless.com
Your Environment Information ---------------------------
OS: darwin
Node Version: 10.15.3
Serverless Version: 1.44.1
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
About this issue
- Original URL
- State: closed
- Created 5 years ago
- Reactions: 6
- Comments: 23 (14 by maintainers)
UPDATE: as stated in this comment, serverless-plugin-typescript is not needed when using serverless-webpack.
I found out that the order the plugins that appear in
serverless.ymlmatters in these cases, in particular usingpermits to compile without any errors.
The importance of the order is reported in the serverless-plugin-typescript docs page, but ignored in other pages. Could be useful to mention this across all the plugin doc pages that may be involved in this behavior.
bump?
Can anyone help with this? I’m still unable to make it work.
Reducing your handler to a minimal, it is working without problem.
I happened to produce a similar error when using
serverless-webpackin tandem withserverless-plugin-typescript, if that’s actually the case, this is not related toserverless-offlineand is not supported.@softmarshmallow See my last comment https://github.com/serverless-heaven/serverless-webpack/issues/511#issuecomment-974227239 for context.
If you believe you are facing a different problem, please open a new issue.