serverless-plugin-typescript icon indicating copy to clipboard operation
serverless-plugin-typescript copied to clipboard

`serverless package/deploy` throws "Path must be a string. Received undefined"

Open venkatramachandran opened this issue 7 years ago • 2 comments

Here is a reproducible test case. To reproduce the error:

  1. Run git clone https://github.com/venkatramachandran/ts-sample
  2. Run cd ts-sample
  3. Run npm run make
  4. 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.

venkatramachandran avatar Feb 02 '18 01:02 venkatramachandran

Did you ever find a resolution for this?

brianeletype avatar Aug 17 '18 17:08 brianeletype

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.

undsoft avatar Mar 11 '19 16:03 undsoft