Db-connection fails while application works

PS F:\MongoDBUniversity\M220\mflix-js> npm test -t db-connection

server@1.0.0 test F:\MongoDBUniversity\M220\mflix-js
jest --passWithNoTests “db-connection”

Error: Plugin/Preset files are not allowed to export objects, only functions. In F:\MongoDBUniversity\M220\mflix-js\node_modules\babel-preset-stage-1\lib\index.js
at createDescriptor (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-descriptors.js:178:11)
at items.map (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-descriptors.js:109:50)
at Array.map ()
at createDescriptors (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-descriptors.js:109:29)
at createPresetDescriptors (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-descriptors.js:101:10)
at presets (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-descriptors.js:47:19)
at mergeChainOpts (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-chain.js:320:26)
at F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-chain.js:283:7
at buildRootChain (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\config-chain.js:120:22)
at loadPrivatePartialConfig (F:\MongoDBUniversity\M220\mflix-js\node_modules@babel\core\lib\config\partial.js:85:55)
npm ERR! Test failed. See above for more details.

Please show the package.json file

TLDR; - You appear to have a dependency issue. Clean install the project.


More Completely

If you read similar posts already in this forum which basically have the same title ( which is what those sticky notes up the top of the posts are also asking you to do ), you will likely find that similar reports mention either an older NodeJS version OR what is actually the current development series being v11.x.

It is strongly advised you do not run anything other than current LTS releases of NodeJS. Generally that should be advisable to be an 8.x series release at minimum and then a 10.x release as recommended. Both should support the presented code and dependencies.

It is also advisable you use a Node Environment Manager as applicable to your OS in preference to simply using a system install of NodeJS. This will allow you better isolation of environment by projects and avoids confilicts with anything that may be dependent on a system path install.

It is also highly unadvisable to edit package.json content or otherwise manually install updated or alternate npm package versions of dependencies. As far as the course content is concerned, a clean directory and node installation ( preferably with environment isolation ) and simple npm install ( or npm i for people who like brevity ) is enough. Ignore the warnings ( as they are not errors or problems you need to be aware of ) and simply get on with the task of going through the lessons.

So if you see errors coming from “babel” or other package dependencies, then it’s your environment that is the problem, and there are plenty of resources on the wider internet to refer to as to how to set up a NodeJS environment correctly for your OS.

My problem was due to npm reporting 500+ vulnerabilities with the packages.json, so I ran
npm audit fix as recommended. I deleted content of node_modules before the second attempt, restored the packages.json from the zip file. This time I ignored all warnings about vulnerabilities and then everything worked well.
FYI I did check for similar issues and I could not find any meaningful explanation on what I need to check.

I’ve never heard of Node Environment Manager, I will check what it does.

PS F:\MongoDBUniversity\M220\mflix-js> node --version
v8.11.4

FYI I did nothing other than unpacking and typing npm install, then I got warnings in red and ran npm audit fix, as it was recommended.

Thanks

Well yes. So the basic summary is DON’T Audit Fix.

It’s not your application you are maintaining, so you should not be presuming to make changes to those parts (being the dependencies).

FYI the Recommendation from npm is for the package author to look into. And that as noted is not you.

Yeah, I know this is even worse than dll hell :slight_smile:

I only think now, why application works after audit fix? :slight_smile: It seems to me that the test harness (or whatever it is called in js world) is not of the best quality.

Yes, should not run “npm audit fix”. Keep everything out of the box. It works for me.