Picture of Ailiniyazi Maimaiti
Error: Cannot find module 'mongodb'
by Ailiniyazi Maimaiti - Thursday, 24 October 2019, 9:46 AM
 

Hi.

 

Today I saw that there is an upgrade at Adapt Authoring Tools, then I tried to upgrade it by running - node upgrade.js


Then I got:

Node dependencies installed successfully. Web application built successfully. Server has been updated successfully! Adapt authoring tool upgraded to v0.10.1 internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module '../../document' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at compile (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\node_modules\mongoose\lib\services\document\compile.js:18:26) at Model.Document.$__setSchema (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\node_modules\mongoose\lib\document.js:1918:3) at Function.compile (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\node_modules\mongoose\lib\model.js:3955:19) at Mongoose.model (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\node_modules\mongoose\lib\index.js:437:22) at NativeConnection.Connection.model (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\node_modules\mongoose\lib\connection.js:1054:23) at exports.default (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\dist\db.js:41:23) at new Migrator (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\migrate-mongoose\dist\lib.js:102:39) at C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\lib\installHelpers.js:314:22 at xfs.stat (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\fs-extra\lib\mkdirs\mkdirs.js:56:16) at callback (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\graceful-fs\polyfills.js:295:20) at FSReqWrap.oncomplete (fs.js:154:5)

When I tried to launch the server by running - node server, I got this error:

internal/modules/cjs/loader.js:638 throw err; ^ Error: Cannot find module 'mongodb' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:636:15) at Function.Module._load (internal/modules/cjs/loader.js:562:25) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\node_modules\connect-mongodb-session\index.js:5:17) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\lib\application.js:39:20) at Module._compile (internal/modules/cjs/loader.js:776:30) at Object.Module._extensions..js (internal/modules/cjs/loader.js:787:10) at Module.load (internal/modules/cjs/loader.js:653:32) at tryModuleLoad (internal/modules/cjs/loader.js:593:12) at Function.Module._load (internal/modules/cjs/loader.js:585:3) at Module.require (internal/modules/cjs/loader.js:690:17) at require (internal/modules/cjs/helpers.js:25:18) at Object. (C:\xampp\htdocs\adapt\adapt_authoring\adapt_authoring_testing\server.js:1:13) at Module._compile (internal/modules/cjs/loader.js:776:30)

Picture of Ailiniyazi Maimaiti
Re: Error: Cannot find module 'mongodb'
by Ailiniyazi Maimaiti - Friday, 25 October 2019, 3:30 PM
 

Has anybody the same problem?

Picture of Tom Greenfield
Re: Error: Cannot find module 'mongodb'
by Tom Greenfield - Tuesday, 29 October 2019, 9:44 AM
 

The first error looks to be a symptom of the Node dependencies being upgraded while still use – this can, in theory, be ignored since the module in question is migrate-mongoose, and there aren't any migrations bundled with the 0.10.1 release.

The second error, however, is more crucial. I suggest you try reinstalling the dependencies and rebuilding the app by running:

rm -r node_modules
npm install --production
grunt build:prod
node server
Picture of Tom Greenfield
Re: Error: Cannot find module 'mongodb'
by Tom Greenfield - Monday, 18 November 2019, 9:30 AM
 
Error: Cannot find module 'mongodb'

We actually ran into this the other day on one of our authoring tool instances.

To resolve, we had to navigate to the node_modules/connect-mongodb-session directory and manually run npm install.

Requires further investigation to ascertain the cause and a proper solution.

Tim Baker
Re: Error: Cannot find module 'mongodb'
by Tim Baker - Monday, 18 November 2019, 3:21 PM
 

Tom's proposed solution worked for me. I was updating from a previous version of the Authoring Tool (0.10.0 ??, but I am not sure)

Here is the console output just in case it gives someone a clue about what has gone wrong:

>npm install

npm WARN deprecated istanbul@0.4.5: This module is no longer maintained, try this instead:

npm WARN deprecated   npm i nyc

npm WARN deprecated Visit https://istanbul.js.org/integrations for other alternatives.

npm WARN deprecated json3@3.3.2: Please use the native JSON object instead of JSON 3

npm notice created a lockfile as package-lock.json. You should commit this file.

npm WARN connect-mongodb-session@2.2.0 No license field.

 

added 160 packages from 480 contributors and audited 241 packages in 26.77s

found 14 vulnerabilities (6 low, 2 moderate, 5 high, 1 critical)

  run `npm audit fix` to fix them, or `npm audit` for details

 

  

>npm audit fix

npm WARN connect-mongodb-session@2.2.0 No license field.

+ acquit@1.0.5

+ express@4.17.1

+ express-session@1.17.0

added 20 packages from 14 contributors, removed 4 packages and updated 19 packages in 10.767s

fixed 12 of 14 vulnerabilities in 241 scanned packages

  1 package update for 2 vulns involved breaking changes

  (use `npm audit fix --force` to install breaking changes; or refer to `npm audit` for steps to fix these manually)

 

 

adapt_authoring>node server

info [18 Nov 19 11:32:03 +01:00] configuration loaded from C:\Users\tbaker\Documents\adapt_authoring\conf\config.json

info [18 Nov 19 11:32:04 +01:00] Supporting the following authentication types:

info [18 Nov 19 11:32:04 +01:00] - local

info [18 Nov 19 11:32:06 +01:00] Connection established: adapt-tenant-master

warn [18 Nov 19 11:32:06 +01:00] MongooseDB#addModel: can't overwrite an existing model

error [18 Nov 19 11:32:06 +01:00] Error importing content schema: MongooseDB#addModel - Failed to add the model course: it already exists

info [18 Nov 19 11:32:09 +01:00] Adapt authoring tool 0.10.2.

info [18 Nov 19 11:32:09 +01:00] Adapt framework 2.4.0.

info [18 Nov 19 11:32:10 +01:00] Server started listening on port 5000

=================================

and it works!

Picture of Stephen Harlow
Re: Error: Cannot find module 'mongodb'
by Stephen Harlow - Monday, 18 November 2019, 9:19 PM
 

Thanks Tom, that worked for me.

Picture of Stephen Harlow
Re: Error: Cannot find module 'mongodb'
by Stephen Harlow - Monday, 18 November 2019, 3:02 AM
 

Yup, just had the exact same problem. Tom's idea hasn't fixed it for me either. How did you get on?

Picture of Ailiniyazi Maimaiti
Re: Error: Cannot find module 'mongodb'
by Ailiniyazi Maimaiti - Monday, 18 November 2019, 8:41 AM
 

I wasn't able to fixed it, so I backed up my custom files and contents from temp folder and reinstalled authoring tool.

Picture of Ailiniyazi Maimaiti
Re: Error: Cannot find module 'mongodb'
by Ailiniyazi Maimaiti - Tuesday, 7 January 2020, 3:53 PM
 

Today I had have the same problem. Then I tried to switch node version to the same node version, which is used during the first installation, then removed node_modules folder and installed node modules again, finally I upgraded Authoring Tool successfully. Hope this may help...