question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

serverless-bundle v5: TypeError: Cannot read property '1' of null

See original GitHub issue

I just tried upgrading to v5 I am getting Webpack build failure.

My project does not have a webpack config file. When I remove the plugin from the package it eventually builds. Also when I downgrade to 4.4.0, it works as expected.

Not sure where to raise this issue.

I am using sls webpack command for building locally and on CI/CD server.

Serverless: Bundling with Webpack...

 Type Error ----------------------------------------------

  TypeError: Cannot read property '1' of null
      at getExternalModuleName (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:31:61)
      at isExternalModule (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:44:77)
      at getExternalModules (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:75:9)
      at __PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:102:24
      at arrayMap (__PROJECT_PATH__/node_modules/lodash/lodash.js:653:23)
      at Function.map (__PROJECT_PATH__/node_modules/lodash/lodash.js:9622:14)
      at __PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:100:14
      at finalCallback (__PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:425:32)
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:489:17
      at __PROJECT_PATH__/node_modules/webpack/lib/HookWebpackError.js:68:3
      at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
      at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
      at Cache.storeBuildDependencies (__PROJECT_PATH__/node_modules/webpack/lib/Cache.js:122:37)
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:485:19
      at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
      at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:482:23
      at Compiler.emitRecords (__PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:874:39)
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:474:11
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:856:14
      at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:15:1)
      at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:853:27
      at __PROJECT_PATH__/node_modules/neo-async/async.js:2818:7
      at done (__PROJECT_PATH__/node_modules/neo-async/async.js:3522:9)
      at Hook.eval [as callAsync] (eval at create (__PROJECT_PATH__/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
      at __PROJECT_PATH__/node_modules/webpack/lib/Compiler.js:707:33
      at __PROJECT_PATH__/node_modules/graceful-fs/graceful-fs.js:143:16
      at __PROJECT_PATH__/node_modules/graceful-fs/graceful-fs.js:61:14
      at FSReqCallback.oncomplete (fs.js:180:23)
  From previous event:
      at webpackCompile (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:89:64)
      at BbPromise.map.concurrency.concurrency (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:108:43)
  From previous event:
      at webpackConcurrentCompile (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:108:20)
      at ServerlessPlugin.compile (__PROJECT_PATH__/node_modules/serverless-webpack/lib/compile.js:125:12)
  From previous event:
      at Object.webpack:compile:compile [as hook] (__PROJECT_PATH__/node_modules/serverless-webpack/index.js:164:61)
      at PluginManager.invoke (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:579:20)
      at PluginManager.spawn (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:601:16)
      at ServerlessPlugin.<anonymous> (__PROJECT_PATH__/node_modules/serverless-webpack/index.js:156:53)
      at processImmediate (internal/timers.js:464:21)
  From previous event:
      at Object.webpack:webpack [as hook] (__PROJECT_PATH__/node_modules/serverless-webpack/index.js:156:12)
      at PluginManager.invoke (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:579:20)
      at PluginManager.run (__PROJECT_PATH__/node_modules/serverless/lib/classes/PluginManager.js:639:18)
      at async Serverless.run (__PROJECT_PATH__/node_modules/serverless/lib/Serverless.js:452:5)
      at async __PROJECT_PATH__/node_modules/serverless/scripts/serverless.js:795:9

     For debugging logs, run again after setting the "SLS_DEBUG=*" environment variable.

  Get Support --------------------------------------------
     Docs:          docs.serverless.com
     Bugs:          github.com/serverless/serverless/issues
     Issues:        forum.serverless.com

  Your Environment Information ---------------------------
     Operating System:          darwin
     Node Version:              14.17.3
     Framework Version:         2.57.0 (local)
     Plugin Version:            5.4.4
     SDK Version:               4.3.0
     Components Version:        3.17.0

Issue Analytics

  • State:open
  • Created 2 years ago
  • Reactions:19
  • Comments:11 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
jayaircommented, Sep 5, 2021

If you can confirm that this fixes the issue, please submit a PR and I’ll cut a release with it.

5reactions
sbhimani-splunkcommented, Sep 7, 2021

For me it worked with webpack version 5.51.2

complete package.json

  "dependencies": {
    "aws-sdk": "^2.978.0",
    "serverless-webpack": "",
    "webpack-node-externals": "",
    "webpack": "5.51.2",
    "babel-loader": "",
    "@babel/core": "",
    "babel-plugin-source-map-support": "",
    "@babel/preset-env": ""
  }
}
Read more comments on GitHub >

github_iconTop Results From Across the Web

Serverless Typescript Error : TypeError: Cannot read property ...
TypeError : Cannot read property '1' of null. Stack - Serverless backend with Typescript,Node.js and AWS Lambda. Using serverless-webpack ...
Read more >
cannot read properties of null (reading 'package') - You.com
The error message means that npm is trying to read the version property of the folder's package.json file but doesn't find the file....
Read more >
Serverless-bundle NPM - npm.io
serverless -bundle is a Serverless Framework plugin that optimally packages your ES6 or TypeScript Node.js Lambda functions with sensible defaults so you ...
Read more >
Serverless Webpack - Serverless Framework: Plugins
Serverless plugin to bundle your lambdas with Webpack ... This allows to set properties in the webpack configuration differently depending if the lambda ......
Read more >
serverless/serverless - Gitter
TypeError : Cannot read property 'getName' of undefined at Project. ... nice work @ac360 , I was able to upgrade serverless 5.0. really...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found