oracle 错误:找不到模块“babel-register”

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53748871/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:32:23  来源:igfitidea点击:

Error: Cannot find module 'babel-register'

node.jsoracleexpressnodemon

提问by Matt H.

I am currently working on a projects that involves making an oracle connecting to an express back-end. The environment was already implemented and pushed to a repository on github. I cloned the project and ran npm install to get all the packages needed for the project. Then I tried to run the project and got this error:

我目前正在从事一个项目,该项目涉及使 oracle 连接到快速后端。该环境已经实现并推送到 github 上的存储库。我克隆了该项目并运行 npm install 以获取该项目所需的所有包。然后我尝试运行该项目并收到此错误:

module.js:550
   throw err;
   ^

Error: Cannot find module 'babel-register'
    at Function.Module._resolveFilename (module.js:548:15)
    at Function.Module._load (module.js:475:25)
    at Module.require (module.js:597:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (C:\xxxx\xxxx\Documents\Work\ef-backend\bin\www:1:63)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)
    at Module.load (module.js:566:32)
    at tryModuleLoad (module.js:506:12)
    at Function.Module._load (module.js:498:3)
[nodemon] app crashed - waiting for file changes before starting...

I then proceeded npm install babel-register thinking maybe the package made it into the gitignore. After the package was installed, I tried to run the project once more and continued to get the same error.

然后我继续 npm install babel-register 想也许这个包已经进入了 gitignore。安装包后,我再次尝试运行该项目并继续出现相同的错误。

回答by Matt H.

I have resolved this issue myself, it was actually an issue with package-lock file being out of sync with the package file. I deleted the package-lock file and npm installed. This then allowed my project to run correctly.

我自己已经解决了这个问题,实际上是包锁定文件与包文件不同步的问题。我删除了 package-lock 文件并安装了 npm。然后这允许我的项目正确运行。

回答by MrDev

in my case my script had an error:

在我的情况下,我的脚本有一个错误:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node --require 'babel-register' src/index.js"
  }

I had to edit my script by removing quotesin babel-register, the correct statement was:

我不得不通过删除babel-register 中的引号来编辑我的脚本,正确的语句是:

"scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node --require babel-register src/index.js"
  }