Browser bundle contains NodeJS code that throws "Uncaught TypeError: Cannot read properties of undefined (reading 'split')"
See original GitHub issuePrerequisites
- I have written a descriptive issue title
- I have searched existing issues to ensure the bug has not already been reported
Mongoose version
6.3.8
Node.js version
16.14.0
MongoDB server version
4.2.19
Description
When bundling up mongoose
for the browser this code is included from the file dist/browser.umd.js
:
e.nodeMajorVersion=parseInt(t.versions.node.split(".")[0],10);
It throws this error in Chrome:
Uncaught TypeError: Cannot read properties of undefined (reading 'split')
My guess is that the code line above was never supposed to end up in the browser bundle because it is server-side node code.
Steps to Reproduce
See the browser.umd.js
file in the dist
folder of mongoose
.
Expected Behavior
The browser.umd.js
contains only browser-compatible code.
Issue Analytics
- State:
- Created a year ago
- Comments:15 (3 by maintainers)
Top Results From Across the Web
TypeError: Cannot read Property 'split' of Undefined in JS
The "Cannot read property 'split' of undefined" error occurs when trying to call the `split()` method on a variable that stores an `undefined`...
Read more >Uncaught TypeError: Cannot read property 'split' of undefined
If og_date contains the date, it's probably a string, so og_date.value is undefined. Simply use og_date.split('-') instead of og_date.value.
Read more >Cannot Read Property 'split' of Undefined - freeCodeCamp
it will throw the TypeError: Cannot read property 'split' of undefined error. ... It then returns an array containing the substrings:
Read more >cannot read properties of undefined (reading 'split') mongoose
Automattic/mongooseBrowser bundle contains NodeJS code that throws "Uncaught TypeError: Cannot read properties of undefined (reading 'split')"#11943.
Read more >Uncaught TypeError: Cannot read property of undefined In
JavaScript TypeError is thrown when an operand or argument passed to a function is incompatible with the type expected by that operator or...
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 FreeTop 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
Top GitHub Comments
I am also experiencing this issue with mongoose 6.5.5 on node 16.17.
I can reproduce with a simplified example:
Downgrading to mongoose 6.5.2 removes the nodeMajorVersion reference.
Has this issue been resolved??? If so, how do I implement the latest release of mongoose?
Thank you! Cheryl