denoland / deno

A modern runtime for JavaScript and TypeScript.
https://deno.com
MIT License
98.21k stars 5.41k forks source link

npm:mongoose not working on dev environment #20197

Open ahmetcanozcan opened 1 year ago

ahmetcanozcan commented 1 year ago

Hey there,

I'm building a simple web application using an npm module called mongoose. it works well when I'm running the deno task preview command. But when I'm running the deno task start command, the error occurred:

error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'prototype')
    at file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/mongoose/7.4.3/lib/types/buffer.js:156:17
    at Object.exports.each (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/mongoose/7.4.3/lib/utils.js:957:5)
    at Object.<anonymous> (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/mongoose/7.4.3/lib/types/buffer.js:145:7)
    at Object.<anonymous> (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/mongoose/7.4.3/lib/types/buffer.js:279:4)
    at Module._compile (node:module:731:36)
    at Object.Module._extensions..js (node:module:745:12)
    at Module.load (node:module:656:34)
    at Function.Module._load (node:module:539:16)
    at Module.require (node:module:675:23)
    at require (node:module:789:20)

When im using different version of mongoose as declared on deno doc such as npm:mongoose@^6.7, a different error occurred:

error: Uncaught (in promise) TypeError: Cannot read properties of undefined (reading 'browser')
    at detectRandomBytes (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/bson/4.7.2/lib/parser/utils.js:29:17)
    at Object.<anonymous> (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/bson/4.7.2/lib/parser/utils.js:55:23)
    at Object.<anonymous> (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/bson/4.7.2/lib/parser/utils.js:116:4)
    at Module._compile (node:module:731:36)
    at Object.Module._extensions..js (node:module:745:12)
    at Module.load (node:module:656:34)
    at Function.Module._load (node:module:539:16)
    at Module.require (node:module:675:23)
    at require (node:module:789:20)
    at Object.<anonymous> (file:///C:/Users/USER/AppData/Local/deno/npm/registry.npmjs.org/bson/4.7.2/lib/ensure_buffer.js:6:15)

For the both case, it works well on deno task preview

Thanks

marvinhagemeister commented 1 year ago

Transfering to the deno repo, because it's an issue with the npm compatibility layer instead of in Fresh.