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

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

Open
venkatramachandran opened this issue Feb 2, 2018 · 2 comments

Comments

@venkatramachandran
Copy link

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.

@brianeletype
Copy link

Did you ever find a resolution for this?

@undsoft
Copy link

undsoft commented Mar 11, 2019

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.

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

No branches or pull requests

3 participants