Cannot find module with serverless-offline (looking in .build/.webpack instead of .webpack)
See original GitHub issueThis is a (Bug Report)
Description
For bug reports:
- What went wrong? I am using serverless-webpack with typescript and want to use serverless-offline everything compile and run properly, but when try to call the handler through API route, noticed the path it referring is wrong.
offline: Failure: Cannot find module '/Users/nader/Projects/company/4m-bamboohr-xero-integration/.build/.webpack/service/src/functions/approved-leaves/getTimeOffRequests'
-
What did you expect should have happened? expected it to be
offline: Failure: Cannot find module '/Users/nader/Projects/company/4m-bamboohr-xero-integration/.webpack/service/src/functions/approved-leaves/getTimeOffRequests'
-
What was the config you used? webpack config
mode: isLocal ? 'development' : 'production',
entry: slsw.lib.entries,
devtool: isLocal ? 'cheap-module-eval-source-map' : 'source-map',
resolve: {
extensions: ['.mjs', '.json', '.ts'],
symlinks: false,
cacheWithContext: false,
},
output: {
devtoolModuleFilenameTemplate: '[absolute-resource-path]',
libraryTarget: 'commonjs',
path: path.join(__dirname, '.webpack'),
filename: '[name].js',
},
tsconfig
"compilerOptions": {
"lib": ["es2017"],
"module": "commonjs",
"removeComments": true,
"moduleResolution": "node",
"noUnusedLocals": true,
"noUnusedParameters": true,
"esModuleInterop": true,
"allowSyntheticDefaultImports": true,
"sourceMap": true,
"target": "es2017",
"outDir": ".build",
"sourceRoot": "/",
"rootDir": "./src"
},
Similar or dependent issue(s):
Additional Data
- Serverless-Webpack Version you’re using: 5.3.2
- Webpack version you’re using:4.29.0
- Serverless Framework Version you’re using:1.74.1
- Operating System: macOS
- Stack Trace (if available):
Issue Analytics
- State:
- Created 3 years ago
- Comments:8 (2 by maintainers)
Top Results From Across the Web
serverless-webpack - npm
A Serverless Framework plugin to build your lambda functions with Webpack. This plugin is for you if you want to use the latest...
Read more >aws + serverless + webpack => cannot find module xxx in prod
One possible solution to the error is to remove the src/ from the handler of the function in serverless.yml file. This approach has...
Read more >serverless-offline/community - Gitter
Hi all, I'm getting a MODULE_NOT_FOUND error from InProcessRunner.js when trying to use Lambda#invoke on another function running in my serverless offline ...
Read more >Serverless Webpack in Lambda Simplified 101 - Learn | Hevo
This blog explains the different aspects of Serverless Webpack in Lambda. In addition to that, it describes AWS Lambda as well.
Read more >Setting up a Serverless Project with Webpack, Babel, and Knex
The solution I went for is to use a Babel plugin to transform ESM to CommonJS Modules which is the standard for Node...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
@nitronaj I fixed this by removing
serverless-plugin-typescript
and leavingserverless-webpack
alone. If you think of it you don’t need both because you compile the code with webpack. So when you are using both these plugins typescript code is compiled by both and there is some mess created.Thanks @LukaszKuciel took me waaay too long to find this thread