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
TypeError: t.versions.node is undefined #12392
Comments
@vkarpov15 can you help me here? i have updated to mongoose 6.6.0 but nothing changed so far.. |
Hello, |
have you managed something? - i can revert my code but as soon as i update my packages - its all garbage.. |
Can you provide a simple replication repository? |
Sure: https://github.com/lapoguidi/sveltekit-mongoose-http-500 I followed just the instructions I reported on README.md and after the start is running, the console.log is executed, but just after an HTTP 500 is received and inside the console I can read: TypeError: Cannot read properties of undefined (reading 'split'). This is the code I've got in node_modules Maybe is useful to know that I tried with: Sveltekit is the latest v1.0.0-next.481 with vite v3.1.0 (rollup v2.78.1) Thank you for the interest. |
Same issue here, using |
@KonghaYao Hi there, i did that in my node_modules/mongoose/dist/browser....js and it solves the issue locally - but when i push it to vercel it displays the same error.. please checkout www.sanivio.de to see in production. |
@alexredder Oh, You need to move the dist/browser.umd.js file to your project folder, because your project upload and bundle your source code with mongoose which has the same bug! You can write an alias redirect your import to the new file path. 😀 |
@KonghaYao sorry.. i dont understand can you please explain in more detail where to put it? .. |
@alexredder 1. You can put browser.js to any path in your project ,like /src/lib/browser.js, |
I dont know. I played around and it seems that svelte has no global window object, so we can not detect if we have a browser or not. |
Editing browser.umd.js is not a so useful solution, because everytime that the dependencies are rebuilded, it will be overwritten. |
Just an update. I manually downloaded from npmjs registry the mongoose packages starting from latest v6.6.2 untill v6.5.2 using an url like this: https://registry.npmjs.org/mongoose/-/mongoose-6.6.2.tgz. Then I simply cloned the v6.6.2 repository and tried to build the browser.umd.js.
Beside that, just a couple of questions (for curiosity):
Thanks for helping me. |
Update: installing Mongoose version 6.5.2 fixed it for now.. |
Some parts of the issue seem to be related to gh-12576. The @lapoguidi it may be the root cause of the file content differences you observe, but I did not verify on the versions you mention. |
Confirmed fixed by #12577 |
Prerequisites
Mongoose version
6.6.0
Node.js version
17.6.0
MongoDB server version
where do i find that?
Description
Hey guys,
one day i open my application and suddenly only the following error message pops up:
I have not changed the code except for updating mongoose.. but i could find out what that error meant or how i can solve it..
this is what it says in chrome:
I am a newbie so i dont know how to solve this issue.. hope you guys can help me out :)
cheers
Steps to Reproduce
the error message points to
node_modules\mongoose\dist\browser.umd.js (220:268)
line 220 intails the following code:
e.noop=function(){},e.errorToPOJO=function(t){if(!(t instanceof Error))throw new Error("
errormust be
instanceof Error.");var e,r={},o=n(Object.getOwnPropertyNames(t));try{for(o.s();!(e=o.n()).done;){var i=e.value;r[i]=t[i]}}catch(t){o.e(t)}finally{o.f()}return r},e.nodeMajorVersion=parseInt(t.versions.node.split(".")[0],10)}).call(this,r(10))},function(t,e,r){"use strict";(function(t){
My Mongo_URI is coming from my .env file
This is my connect code:
const connection = {};
const testvar = process.versions.node;
async function connect() {
if (connection.isConnected) {
console.log('already connected');
return;
}
if (mongoose.connections.length > 0) {
connection.isConnected = mongoose.connections[0].readyState;
if (connection.isConnected === 1) {
console.log('use previous connection');
return;
}
await mongoose.disconnect();
}
const db = await mongoose.connect(process.env.MONGODB_URI);
console.log('new connection');
connection.isConnected = db.connections[0].readyState;
}
console.log(testvar);
async function disconnect() {
if (connection.isConnected) {
if (process.env.NODE_ENV === 'production') {
await mongoose.disconnect();
connection.isConnected = false;
} else {
console.log('not disconnected');
}
}
}
function convertDocToObj(doc) {
doc._id = doc._id.toString();
doc.createdAt = doc.createdAt.toString();
doc.updatedAt = doc.updatedAt.toString();
return doc;
}
const db = { connect, disconnect, convertDocToObj };
export default db;
`
UPDATE
i have reset the application to a former state.. now it works in dev-environment but not in my vercel deployment..
Expected Behavior
run smoothly like it did before.. aswell in deployment as development
The text was updated successfully, but these errors were encountered: