Cannot find module './drivers/node-mongodb-native/connection'
See original GitHub issuethis a 🐛 bug report
hi,
i’m trying to bundle a nodejs app (using mongoose) with parceljs. the bundle succeeds but when i try to run the bundled file, i get the follwing error.
Cannot find module ‘./drivers/node-mongodb-native/connection’
🎛 Configuration (.babelrc, package.json, cli command)
.babelrc
{
"presets": ["@babel/preset-env"]
}
tsconfig.json
{
"compilerOptions": {
"baseUrl": ".",
"module": "CommonJS",
"target": "ESNext",
"allowJs": true
}
}
package.json
{
"scripts": {
"bundle": "parcel build ./src/index.js --target node --bundle-node-modules"
},
"dependencies": {
"@babel/runtime": "^7.7.7",
"@pnp/common": "^1.3.8",
"@pnp/graph": "^1.3.8",
"@pnp/logging": "^1.3.8",
"@pnp/nodejs": "^1.3.8",
"@pnp/odata": "^1.3.8",
"@types/dotenv": "^8.2.0",
"@types/express": "^4.17.2",
"@types/mongoose": "^5.5.38",
"@types/ramda": "^0.26.39",
"@types/socket.io": "^2.1.4",
"adal-node": "^0.2.1",
"axios": "^0.19.0",
"body-parser": "^1.19.0",
"cors": "^2.8.5",
"dotenv": "^8.2.0",
"express": "^4.17.1",
"i18next": "^19.0.3",
"i18next-express-middleware": "^1.9.1",
"i18next-node-fs-backend": "^2.1.3",
"jsonwebtoken": "^8.5.1",
"jwks-rsa": "^1.6.0",
"log4js": "^6.1.0",
"luxon": "^1.21.3",
"memory-cache": "^0.2.0",
"mongoose": "^5.8.9",
"ramda": "^0.26.1",
"socket.io": "^2.3.0",
"uws": "github:mmdevries/uws#2.4.1"
},
"devDependencies": {
"@babel/core": "^7.7.7",
"@babel/node": "^7.7.7",
"@babel/plugin-transform-runtime": "^7.7.6",
"@babel/preset-env": "^7.7.7",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"babel-plugin-rewire": "^1.2.0",
"cross-env": "^6.0.3",
"eslint": "^6.8.0",
"eslint-config-babel": "^9.0.0",
"eslint-plugin-flowtype": "^4.5.3",
"jest": "^24.9.0",
"moxios": "^0.4.0",
"nodemon": "^2.0.2",
"parcel-bundler": "^1.12.4",
"supertest": "^4.0.2"
}
}
🤔 Expected Behavior
i expect to execute npm run bundle and get an index.js that works 😃
😯 Current Behavior
/usr/src/server/dist/index.js:1
parcelRequire=function(e,r,t,n){var i,o="function"==typeof parcelRequire&&parcelRequire,u="function"==typeof require&&require;function f(t,n){if(!r[t]){if(!e[t]){var i="function"==typeof parcelRequire&&parcelRequire;if(!n&&i)return i(t,!0);if(o)return o(t,!0);if(u&&"string"==typeof t)return u(t);var c=new Error("Cannot find module '"+t+"'");throw c.code="MODULE_NOT_FOUND",c}p.resolve=function(r){return e[t][1][r]||r},p.cache={};var l=r[t]=new f.Module(t);e[t][0].call(l.exports,p,l,l.exports,this)}return r[t].exports;function p(e){return f(p.resolve(e))}}f.isParcelRequire=!0,f.Module=function(e){this.id=e,this.bundle=f,this.exports={}},f.modules=e,f.cache=r,f.parent=o,f.register=function(r,t){e[r]=[function(e,r){r.exports=t},{}]};for(var c=0;c<t.length;c++)try{f(t[c])}catch(e){i||(i=e)}if(t.length){var l=f(t[t.length-1]);"object"==typeof exports&&"undefined"!=typeof module?module.exports=l:"function"==typeof define&&define.amd?define(function(){return l}):n&&(this[n]=l)}if(par
Error: Cannot find module './drivers/node-mongodb-native/connection'
Require stack:
- /usr/src/server/dist/index.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:797:15)
at Function.Module._load (internal/modules/cjs/loader.js:690:27)
at Module.require (internal/modules/cjs/loader.js:852:19)
at require (internal/modules/cjs/helpers.js:74:18)
at f (/usr/src/server/dist/index.js:1:293)
at p (/usr/src/server/dist/index.js:1:544)
at Object.parcelRequire.iK3j../driver (/usr/src/server/dist/index.js:1792:5170)
at f (/usr/src/server/dist/index.js:1:468)
at p (/usr/src/server/dist/index.js:1:544)
at Object.parcelRequire.hW9w../lib/ (/usr/src/server/dist/index.js:1794:29)
at f (/usr/src/server/dist/index.js:1:468)
at p (/usr/src/server/dist/index.js:1:544)
at Object.parcelRequire.Focm.@pnp/graph (/usr/src/server/dist/index.js:3460:295)
at f (/usr/src/server/dist/index.js:1:468)
at parcelRequire.e4bP (/usr/src/server/dist/index.js:1:771)
at Object.<anonymous> (/usr/src/server/dist/index.js:1:1023) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/usr/src/server/dist/index.js' ]
}
🌍 Your Environment
Software | Version(s) |
---|---|
Parcel | 1.12.4 |
Node | 12.13.1 |
npm | 6.12.1 |
Operating System | Windows 10 |
Docker | 19.03.5, build 633a0ea |
Issue Analytics
- State:
- Created 4 years ago
- Comments:12 (3 by maintainers)
Top Results From Across the Web
Issues - GitHub
drivers/node-mongodb-native/connection'" comes from. The runtime environment can't find this module because it's never bundled.
Read more >2 - Stack Overflow
Lambda: cannot find module './drivers/node-mongodb-native/connection'", although mongoose layer added · What version of Mongoose are you using? – ...
Read more >nodejs cannot find module mongodb-mongodb - appsloveworld
Check in the folder nodes_modules for the current project, the existence of the mongodb folder. · If it does not exist, open the...
Read more >Solve - cannot find module mongodb in Node.js - Reactgo
The can't find module 'mongodb' error occurs, if you're trying to access a mongodb module that is not present inside your node_modules folder....
Read more >MongoDB Node.js Driver
The official MongoDB Node.js driver allows Node.js applications to connect to MongoDB and work with data. The driver features an asynchronous API which ......
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 completely understand your standpoint, and agree with it as well.
I’m going to continue this over at mongoose. I hope they can find a alternative way to require their modules, like logform did.
Thanks for all the help.
Hello, I’ve ran into this issue while trying to compile and bundle a node app into a single .js file with parcel 2.
My current environment:
My parcel target is setup like this:
The project also has a .babelrc wich looks like this:
Is this a parcel issue, or should i open one over at mongoose?