I have the following error code, i am sure my implementation is correct but i am still have error

when i run the following command i have the following error, help please
npm test -t mongoclient
npm WARN npm npm does not support Node.js v10.15.2
npm WARN npm You should probably upgrade to a newer version of node as we
npm WARN npm can’t make any promises that npm will work with this version.
npm WARN npm Supported releases of Node.js are the latest release of 4, 6, 7, 8, 9.
npm WARN npm You can find the latest version at https://nodejs.org/

server@1.0.0 test /home/coder/Documents/mflix-js
jest --passWithNoTests “mongoclient”

Determining test suites to run…Setup Mongo Connection
FAIL test/lessons/mongoclient.spec.js
● Test suite failed to run

TypeError: Cannot read property 'close' of undefined

  17 | 
  18 |   async teardown() {
> 19 |     await this.global.mflixClient.close()
     |                                   ^
  20 |     await super.teardown()
  21 |   }
  22 | 

  at MongoEnvironment.teardown (test/config/mongoEnvironment.js:19:35)                                                    
      at Generator.throw (<anonymous>)

Test Suites: 1 failed, 1 total
Tests: 0 total
Snapshots: 0 total
Time: 0.177s
Ran all test suites matching /mongoclient/i.
Teardown Mongo Connection
npm ERR! Test failed. See above for more details.

Hey @Clement_Ohiomoje_26072

From the error it seems your npm and node version are not compatable.
Perhaps you can try updating both your node and npm versions

Node can be updated by following this link or the one above.
And npm can be updated by running

npm install -g npm

Hope that helps.

Hey @natac13 i have tried the following command, however i have the following error
checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’
npm ERR! { [Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’]
npm ERR! stack:
npm ERR! ‘Error: EACCES: permission denied, access ‘/usr/local/lib/node_modules’’,
npm ERR! errno: -13,
npm ERR! code: ‘EACCES’,
npm ERR! syscall: ‘access’,
npm ERR! path: ‘/usr/local/lib/node_modules’ }

i think i have the latest version of node
/Documents/mflix-js$ node -v

None of my test seem to pass, please i need help, with setup

Have you tried to redo the setup process? As in delete the folder you downloaded the app files into and following the sets outlined in Chapter 0, especially the last video?

I have followed your recommendation still not working


Are you using a Mac? I found this stackoverflow which may help solve the problem if on a Mac.

If the command I suggested to upgrade npm gave you this new error then try to run it with sudo.

sudo npm install -g npm

@natac13 i have run the command and below is the response
sudo npm install -g npm
/usr/local/bin/npm -> /usr/local/lib/node_modules/npm/bin/npm-cli.js
/usr/local/bin/npx -> /usr/local/lib/node_modules/npm/bin/npx-cli.js

  • npm@6.10.1
    updated 1 package in 6.216s

However when i run npm start i get the following error message

mflix-js$ npm start

server@1.0.0 start /home/coder/Documents/mflix-js
nodemon -L ./index.js

[nodemon] 1.17.5
[nodemon] to restart at any time, enter rs
[nodemon] watching: .
[nodemon] starting node ./index.js
MongoParseError: URI malformed, cannot be parsed
at parseConnectionString (/home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/uri_parser.js:211:21)
at connect (/home/coder/Documents/mflix-js/node_modules/mongodb/lib/operations/mongo_client_ops.js:180:3)
at connectOp (/home/coder/Documents/mflix-js/node_modules/mongodb/lib/operations/mongo_client_ops.js:284:3)
at /home/coder/Documents/mflix-js/node_modules/mongodb/lib/utils.js:437:24
at new Promise ()
at executeOperation (/home/coder/Documents/mflix-js/node_modules/mongodb/lib/utils.js:432:10)
at MongoClient.connect (/home/coder/Documents/mflix-js/node_modules/mongodb/lib/mongo_client.js:168:10)
at Function.MongoClient.connect (/home/coder/Documents/mflix-js/node_modules/mongodb/lib/mongo_client.js:372:22)
at Object. (/home/coder/Documents/mflix-js/src/index.js:23:13)
at Module._compile (internal/modules/cjs/loader.js:689:30)
[nodemon] app crashed - waiting for file changes before starting…

@natac13 i am able to connect to mongo shell but so i don’t know why my npm start is not working
please i need urgent assistance

/Documents/mflix-js$ mongo “mongodb+srv://mflix-wn2d5.mongodb.net/test” --username m220student
MongoDB shell version v3.6.8
Enter password:
connecting to: mongodb+srv://mflix-wn2d5.mongodb.net/test
2019-07-17T09:57:49.696+0100 I NETWORK [thread1] Starting new replica set monitor for mflix-shard-0/mflix-shard-00-00-wn2d5.mongodb.net.:27017,mflix-shard-00-02-wn2d5.mongodb.net.:27017,mflix-shard-00-01-wn2d5.mongodb.net.:27017
2019-07-17T09:57:50.423+0100 I NETWORK [thread1] Successfully connected to mflix-shard-00-02-wn2d5.mongodb.net.:27017 (1 connections now open to mflix-shard-00-02-wn2d5.mongodb.net.:27017 with a 5 second timeout)
2019-07-17T09:57:50.423+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mflix-shard-00-00-wn2d5.mongodb.net.:27017 (1 connections now open to mflix-shard-00-00-wn2d5.mongodb.net.:27017 with a 5 second timeout)
2019-07-17T09:57:50.557+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] changing hosts to mflix-shard-0/mflix-shard-00-00-wn2d5.mongodb.net:27017,mflix-shard-00-01-wn2d5.mongodb.net:27017,mflix-shard-00-02-wn2d5.mongodb.net:27017 from mflix-shard-0/mflix-shard-00-00-wn2d5.mongodb.net.:27017,mflix-shard-00-01-wn2d5.mongodb.net.:27017,mflix-shard-00-02-wn2d5.mongodb.net.:27017
2019-07-17T09:57:51.019+0100 I NETWORK [thread1] Successfully connected to mflix-shard-00-00-wn2d5.mongodb.net:27017 (1 connections now open to mflix-shard-00-00-wn2d5.mongodb.net:27017 with a 5 second timeout)
2019-07-17T09:57:51.128+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mflix-shard-00-01-wn2d5.mongodb.net:27017 (1 connections now open to mflix-shard-00-01-wn2d5.mongodb.net:27017 with a 5 second timeout)
2019-07-17T09:57:51.758+0100 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to mflix-shard-00-02-wn2d5.mongodb.net:27017 (1 connections now open to mflix-shard-00-02-wn2d5.mongodb.net:27017 with a 5 second timeout)
Implicit session: session { “id” : UUID(“6b55090e-6918-491c-98fe-8f094dcb5f06”) }
MongoDB server version: 4.0.10
WARNING: shell and server versions do not match
Error while trying to show server startup warnings: user is not allowed to do action [getLog] on [admin.]
MongoDB Enterprise mflix-shard-0:PRIMARY>

Have you included the Connection string in the .env file? The error says you have a bad connections URI to Mongo.

Have you gone through the steps outlined in the Chapter - 1 Connection Ticket?

Make sure not to wrap your Atlas SRV connection between quotes:

I am not quite sure how to setup the .env file

Which part?

Locate the file called dotenv_win or dotenv_unix (depending on your operating system) and replace the information within with your own srv connection string:


Make sure not to wrap your Atlas SRV connection between quotes:


It’s highly suggested you also change the SECRET_KEY to some very long, very random string. While this application is only meant for local use during this course, software has a strange habit of living a long time.

Rename dotenv_win or dotenv_unix to .env . You can do this by running the following command from the mflix-js directory:

mv dotenv_unix .env # on Unix
ren dotenv_win .env # on Windows

1 Like

@natac13 now i have the following error
MongoError: authentication fail
at /home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/topologies/replset.js:1456:15
at /home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/connection/pool.js:869:7
at /home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/connection/pool.js:845:20
at finish (/home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/auth/scram.js:233:16)
at handleEnd (/home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/auth/scram.js:243:7)
at /home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/auth/scram.js:352:15
at /home/coder/Documents/mflix-js/node_modules/mongodb-core/lib/connection/pool.js:532:18
at process._tickCallback (internal/process/next_tick.js:61:11)
[nodemon] app crashed - waiting for file changes before startin

Thanks for the support, i think my setup is good now


Have you included the correct connection string to the Atlas Cluster

Note: These instructions were included in the README.rst .

  1. First, make sure you’ve created a user on your Atlas cluster with read and write access to the mflix database.
  2. Copy the connection string. Select that you’d like to connect with the Mongo shell, version 3.6 or later . This will give you the srv connection string.

Hi @Clement_Ohiomoje_26072,

Glad to hear that. :slight_smile:

For anyone getting the same error, this error is mostly due to the issue in .env file in the connection string.


1 Like

Hey just wanted to ask if I was wrong in my first estimate of the error being that node and npm were out of sync, in this case npm being too old?

Thanks for the help.

@natac13 @Kanika i don’t think it was a problem with node and npm being out of sync but the problem i was having was that my .env file was not setup properly.

Hi @natac13,

You were right in your diagnosis. And this Warning means current version of npm does not support older version of Node i.e. 10.15.2 in this case.

Here, you can find more detailed information on this one:


1 Like