vendredi 1 novembre 2019

Error: Cannot find module 'babel-core/register' (Chai, Mocha, Node, ES6)

When attempting to run a test, using Chai/Mocha, Node crashes.

package.json

"test": "mocha server/test  --require @babel/core @babel/preset-env @babel/register",

Dependancies

"devDependencies": {
    "@babel/cli": "^7.6.4",
    "@babel/core": "^7.6.4",
    "@babel/node": "^7.6.3",
    "@babel/plugin-proposal-class-properties": "^7.5.5",
    "@babel/preset-env": "^7.6.3",
    "@babel/preset-react": "^7.6.3",
    "@babel/register": "^7.6.2",
    "babel-loader": "^8.0.6",
    "css-loader": "^2.1.1",
    "file-loader": "^4.2.0",
    "mocha": "^6.2.2",
    "npm-run-all": "^4.1.5",

Attempts

I have tried deleting and reinstalling all node modules.

I have tried using different dependacies syntax.

`mocha server/test --require @babel-core/register`

Entire Error

Error: Cannot find module 'babel-core/register'
    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:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at Object.<anonymous> (/Users/jessew/repos/satellite/server/test/test.js:5:1)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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:692:17)
    at require (internal/modules/cjs/helpers.js:25:18)
    at /Users/jessew/repos/satellite/node_modules/mocha/lib/mocha.js:334:36
    at Array.forEach (<anonymous>)
    at Mocha.loadFiles (/Users/jessew/repos/satellite/node_modules/mocha/lib/mocha.js:331:14)
    at Mocha.run (/Users/jessew/repos/satellite/node_modules/mocha/lib/mocha.js:809:10)
    at Object.exports.singleRun (/Users/jessew/repos/satellite/node_modules/mocha/lib/cli/run-helpers.js:108:16)
    at exports.runMocha (/Users/jessew/repos/satellite/node_modules/mocha/lib/cli/run-helpers.js:142:13)
    at Object.exports.handler.argv [as handler] (/Users/jessew/repos/satellite/node_modules/mocha/lib/cli/run.js:292:3)
    at Object.runCommand (/Users/jessew/repos/satellite/node_modules/yargs/lib/command.js:242:26)
    at Object.parseArgs [as _parseArgs] (/Users/jessew/repos/satellite/node_modules/yargs/yargs.js:1087:28)
    at Object.parse (/Users/jessew/repos/satellite/node_modules/yargs/yargs.js:566:25)
    at Object.exports.main (/Users/jessew/repos/satellite/node_modules/mocha/lib/cli/cli.js:68:6)
    at Object.<anonymous> (/Users/jessew/repos/satellite/node_modules/mocha/bin/mocha:164:29)
    at Module._compile (internal/modules/cjs/loader.js:778:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:789: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 Function.Module.runMain (internal/modules/cjs/loader.js:831:12)
    at startup (internal/bootstrap/node.js:283:19)
    at bootstrapNodeJSCore (internal/bootstrap/node.js:622:3)

Aucun commentaire:

Enregistrer un commentaire