bug: Cannot read property '1' of null (not #193)
See original GitHub issueThis is a (Bug Report / Feature Proposal)
Description
For bug reports:
-
What went wrong? When I was doing single deploy, it throws the error
Cannot read property '1' of null
after successful bundling. -
What did you expect should have happened? It correctly deploys.
-
What was the config you used? Quite huge and generated from pipeline env vars, but it shouldn’t matter. Because it is the module identifier changed.
The regular expression below does not match the actual module identifier string
'external commonjs "aws-sdk"'
, https://github.com/serverless-heaven/serverless-webpack/blob/fa2370d8902f4d5e2ad50ab0c06490b6eb9acf0c/lib/compile.js#L31It seems like webpack added the keyword
"commonjs"
in the middle. -
What stacktrace or error message from your provider did you see?
TypeError: Cannot read property '1' of null
at getExternalModuleName (/Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:32:61)
at isExternalModule (/Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:45:77)
at getExternalModules (/Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:76:9)
at /Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:103:24
at arrayMap (/Users/vicary/Documents/[REDACTED]/node_modules/lodash/lodash.js:653:23)
at Function.map (/Users/vicary/Documents/[REDACTED]/node_modules/lodash/lodash.js:9622:14)
at /Users/vicary/Documents/[REDACTED]/node_modules/serverless-webpack/lib/compile.js:101:14
at tryCatcher (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/util.js:16:23)
at Promise._settlePromiseFromHandler (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:547:31)
at Promise._settlePromise (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:604:18)
at Promise._settlePromise0 (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:649:10)
at Promise._settlePromises (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:729:18)
at Promise._fulfill (/Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/promise.js:673:18)
at /Users/vicary/Documents/[REDACTED]/node_modules/bluebird/js/release/nodeback.js:42:21
at finalCallback (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:425:32)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:489:17
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/HookWebpackError.js:68:3
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at Cache.storeBuildDependencies (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Cache.js:122:37)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:485:19
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:24:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:482:23
at Compiler.emitRecords (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:874:39)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:474:11
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:856:14
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/Hook.js:18:14)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:853:27
at /Users/vicary/Documents/[REDACTED]/node_modules/neo-async/async.js:2818:7
at done (/Users/vicary/Documents/[REDACTED]/node_modules/neo-async/async.js:3522:9)
at Hook.eval [as callAsync] (eval at create (/Users/vicary/Documents/[REDACTED]/node_modules/webpack/node_modules/tapable/lib/HookCodeFactory.js:33:10), <anonymous>:6:1)
at /Users/vicary/Documents/[REDACTED]/node_modules/webpack/lib/Compiler.js:707:33
at /Users/vicary/Documents/[REDACTED]/node_modules/graceful-fs/graceful-fs.js:143:16
at /Users/vicary/Documents/[REDACTED]/node_modules/graceful-fs/graceful-fs.js:61:14
at FSReqCallback.oncomplete (node:fs:188:23)
Additional Data
- Serverless-Webpack Version you’re using: 5.5.3
- Webpack version you’re using: 5.38.1
- Serverless Framework Version you’re using: 2.57.0
- Operating System: macOS Big Sur (Apple Silicon)
- Stack Trace (if available): See above
Issue Analytics
- State:
- Created 2 years ago
- Reactions:9
- Comments:7 (5 by maintainers)
Top Results From Across the Web
'TypeError: Cannot read property '1' of null' - Stack Overflow
TypeError: Cannot read property '1' of null means there was no match. First, always check if there is a match before getting the...
Read more >When driver quits, appium throws Cannot read property '1' of null
Anybody have come across similar problem ?? I am using Appium 0.16.0/0.15.0 with selenium webdriver 2.39.0 and Android verison 4.3 emulator -- i...
Read more >uncaught typeerror: cannot read properties of null ... - You.com
1 The error says that jsonObject is null. You are testing if data is null. Therefore data must null expressed as JSON so...
Read more >Uncaught TypeError: Cannot read property of null - iDiallo
This error occurs when you read a property or call a method on a null object . That's because the DOM API returns...
Read more >Uncaught TypeError: Cannot read property '1' of undefined
There are a few variations of this error depending on the property you are trying to access. Sometimes instead of undefined it will...
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
I just hit this as well after upgrading some dependencies. I was able to resolve it by downgrading webpack from 5.52.0 to 5.51.2 (which is very strange to me).
This may also have something to do with NPM bugs. I’ve noticed an issue with the acorn peer dependency from webpack + eslint + jest: if you’re using node 14 + npm 6, npm will fail to find the correct acorn peer dependency for one of webpack’s transitive dependencies. The resolution is to uninstall webpack, jest, and eslint, then install webpack, then install jest and eslint. (Doing all 3 in a single command generates a failure.) Webpack maintainers have identified this as a “bug in npm” (without any further information): https://github.com/webpack/webpack/issues/13935
I finally provided a fix https://github.com/serverless-heaven/serverless-webpack/pull/953