serverless-plugin-typescript
serverless-plugin-typescript copied to clipboard
`serverless package/deploy` throws "Path must be a string. Received undefined"
Here is a reproducible test case. To reproduce the error:
- Run
git clone https://github.com/venkatramachandran/ts-sample - Run
cd ts-sample - Run
npm run make - Run
npm run pack
I get the following error stack at the last step:
Serverless: Packaging service...
Type Error ---------------------------------------------
Path must be a string. Received undefined
For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.
Stack Trace --------------------------------------------
TypeError: Path must be a string. Received undefined
at assertPath (path.js:7:11)
at Object.basename (path.js:1362:5)
at TypeScriptPlugin.<anonymous> (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless-plugin-typescript/dist/src/index.js:162:115)
at next (native)
at fulfilled (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless-plugin-typescript/dist/src/index.js:4:58)
From previous event:
at PluginManager.invoke (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless/lib/classes/PluginManager.js:261:22)
at PluginManager.run (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless/lib/classes/PluginManager.js:292:17)
at variables.populateService.then (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless/lib/Serverless.js:99:33)
at runCallback (timers.js:672:20)
at tryOnImmediate (timers.js:645:5)
at processImmediate [as _immediateCallback] (timers.js:617:5)
From previous event:
at Serverless.run (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless/lib/Serverless.js:86:74)
at serverless.init.then (/mnt/c/Users/venkat.ramachandran/ts-sample/node_modules/serverless/bin/serverless:39:50)
The specific line where this happens is src/index.ts.
Did you ever find a resolution for this?
I don't know what the problem is, but adding
package:
individually: true
to serverless.yml helps.
For debugging purposes, here are files that create a problem. serverless.yml
service: test
plugins:
- serverless-plugin-typescript
- serverless-webpack
- serverless-aws-documentation
- serverless-offline
provider:
name: aws
stage: dev
runtime: nodejs8.10
functions:
location:
handler: controllers/test.controller.index
description: Simple hello world to test things.
memorySize: 512 # default is 1024
tracing: active
events:
- http:
path: index/test
method: get
custom:
webpack:
webpackConfig: '../../../webpack.config.js'
webpack.config.js
// webpack.config.js
const slsw = require('serverless-webpack');
console.log(slsw.lib.entries);
module.exports = {
entry: slsw.lib.entries,
target: 'node',
devtool: 'source-map',
mode: process.env.NODE_ENV || 'development'
};
My code is organized in monorepository using yarn workspaces based on this.