Hey all, having some issues following the <https:/...
# help
j
Hey all, having some issues following the https://serverless-stack.com/chapters/setup-the-serverless-framework.html guide - Getting errors executing locally
serverless invoke local --function hello
on multiple computers and different node versions. Error logs inside the thread.
Copy code
TypeError [ERR_INVALID_ARG_TYPE]: The "from" argument must be of type string. Received undefined
      at validateString (internal/validators.js:120:11)
      at Object.relative (path.js:1053:5)
      at getWebpackConfigPath (/Users/jharrowell/Development/notes-api/node_modules/serverless-bundle/index.js:10:15)
      at applyWebpackOptions (/Users/jharrowell/Development/notes-api/node_modules/serverless-bundle/index.js:21:20)
      at ServerlessPlugin.<anonymous> (/Users/jharrowell/Development/notes-api/node_modules/serverless-bundle/index.js:89:7)
      at PluginManager.invoke (/Users/jharrowell/.nvm/versions/node/v12.22.1/lib/node_modules/serverless/lib/classes/PluginManager.js:552:20)
      at PluginManager.spawn (/Users/jharrowell/.nvm/versions/node/v12.22.1/lib/node_modules/serverless/lib/classes/PluginManager.js:574:16)
      at ServerlessPlugin.<anonymous> (/Users/jharrowell/Development/notes-api/node_modules/serverless-webpack/index.js:93:53)
      at ServerlessPlugin.tryCatcher (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/util.js:16:23)
      at Promise._settlePromiseFromHandler (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/promise.js:547:31)
      at Promise._settlePromise (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/promise.js:604:18)
      at Promise._settlePromiseCtx (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/promise.js:641:10)
      at _drainQueueStep (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/async.js:97:12)
      at _drainQueue (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/async.js:86:9)
      at Async._drainQueues (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/async.js:102:5)
      at Immediate.Async.drainQueues [as _onImmediate] (/Users/jharrowell/Development/notes-api/node_modules/bluebird/js/release/async.js:15:14)
The webpack config is as so, and expects a 
servicePath
 however as you can see it's undefined.
Copy code
{
  servicePath: undefined,
  nodeVersion: 10,
  options: {
    aliases: [],
    stats: false,
    caching: true,
    linting: true,
    fixPackages: [],
    packager: 'npm',
    copyFiles: null,
    concatText: null,
    sourcemaps: true,
    forceInclude: null,
    ignorePackages: [],
    packagerOptions: {},
    tsConfig: 'tsconfig.json',
    forceExclude: [ 'aws-sdk' ],
    externals: [ 'knex', 'sharp' ],
    rawFileExtensions: [ 'pem', 'txt' ]
  }
}
Here's my
serverless.yml
Copy code
# NOTE: update this with your service name
service: notes-api

# Create an optimized package for our functions 
package:
  individually: true

plugins:
  - serverless-bundle # Package our functions with Webpack
  - serverless-offline
  - serverless-dotenv-plugin # Load .env as environment variables

provider:
  name: aws
  runtime: nodejs10.x
  stage: dev
  region: us-east-1
  # To load environment variables externally
  # rename env.example to .env and uncomment
  # the following line. Also, make sure to not
  # commit your .env.
  #
  #environment:
  #  SAMPLE_ENV_VAR: ${env:SAMPLE_ENV_VAR}

functions:
  hello:
    handler: handler.hello
    events:
      - http:
          path: hello
          method: get
j
@Joshua Harrowell in your
package.json
, whats the version of
serverless-bundle
?
j
Using
3.2.0
- Got slightly further where if I change
handler.js
to
exports.hello
then it works. This was after reinstalling the global
serverless
NPM package however I'm getting ES6 errors if I use the default provided by the tutorial. A colleague who's on the same version of node as myself isn't getting this issue so I'm slightly confused 😅
Copy code
Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              12.22.1
     Framework Version:         2.37.0
     Plugin Version:            4.5.3
     SDK Version:               4.2.2
     Components Version:        3.8.3
Basically seems the transpiling isnt working
j
So the only change you made was rename the export?
j
That fixed my initial error, but further into the guide stuff like
import x from y
also doesnt work
This is without any changes from the guide.
Tried doing fresh pulls from the source repo, installing and reinstalling the global serverless and different node versions
j
Oh something seems seriously broken then. And the older version of serverless-bundle didn’t work
j
Yeah, pretty confusing all round - My colleague has no issues but I've got the same issue on 2 machines. I just started my new role on Monday so I'm on a fresh Macbook, but using NVM so don't see that would cause a massive problem
j
Can you try an older version of Serverless Framework?
j
Sure thing, any version you recommend?
j
Hmm not entirely sure. Maybe something from a couple of weeks ago? Let me know what you find. I’ve to step away for a bit.
j
No worries, thanks for the help so far!
Dropped down to
2.35.0
and it worked perfectly, thanks a lot!
j
Wow, that's weird that the latest release completely broke it.