Javascript 找不到模块'@巴别塔/解析器';

Javascript 找不到模块'@巴别塔/解析器';,javascript,npm,babeljs,Javascript,Npm,Babeljs,运行babel时,我无法再传输我的代码库。我做了。这以前没有发生过,我不知道为什么。这只发生在我拉远程主分支时,它有warn.lock冲突。我解决了与warn命令的冲突 这是我的包的一部分。json { "devDependencies": { "@babel/cli": "^7.1.0", "@babel/core": "^7.1.2", "@babel/plugin-proposal-class-properties": "^7.0.0", "@babel

运行
babel
时,我无法再传输我的代码库。我做了。这以前没有发生过,我不知道为什么。这只发生在我拉远程主分支时,它有
warn.lock
冲突。我解决了与
warn
命令的冲突

这是我的
包的一部分。json

{
  "devDependencies": {
    "@babel/cli": "^7.1.0",
    "@babel/core": "^7.1.2",
    "@babel/plugin-proposal-class-properties": "^7.0.0",
    "@babel/plugin-proposal-decorators": "^7.0.0",
    "@babel/plugin-proposal-export-default-from": "^7.0.0",
    "@babel/plugin-proposal-export-namespace-from": "^7.0.0",
    "@babel/plugin-proposal-function-sent": "^7.0.0",
    "@babel/plugin-transform-runtime": "^7.1.0",
    "@babel/polyfill": "^7.0.0",
    "@babel/preset-env": "^7.1.0",
    "@babel/preset-react": "^7.0.0",
    "@babel/register": "^7.0.0",
    ...
  }
}
运行
babel src-d build
会导致以下错误

{ Error: Cannot find module '@babel/parser'
    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 _parser (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/normalize-file.js:59:16)
    at parser (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/normalize-file.js:170:18)
    at normalizeFile (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/normalize-file.js:138:11)
    at runSync (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/index.js:44:43)
    at runAsync (/Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transformation/index.js:35:14)
    at /Users/mohammadmohammad/Dev/work/procore/hydra_clients/budgetViewer/node_modules/@babel/core/lib/transform-file.js:58:36 code: 'MODULE_NOT_FOUND' }

我还尝试删除
node\u模块
,并运行
warn安装
,但没有成功

只需将
babel eslint
8.2,3
跳到
10.0.1
就可以解决这个问题,这对我来说很有效:

纱线添加-D@babel/parser

或使用
NPM

npmi-D@babel/parser


祝你好运…

下面的命令对我有用

npm审核修复-强制


请注意,audit fix安装SemVer主要更新到顶级依赖项,而不仅仅是SemVer兼容的依赖项()

是否删除了锁定的程序包json文件?这可能是一个愚蠢的问题,但为什么不添加@babel/parser?@JoeFitzsimmons我没有。我确实检查了
warn.lock
@babel/parser
exists@ChrisGbabel/parser是babel/core中的一个依赖项,我不应该也不应该直接在我的项目中安装它。@ChrisG,我检查了所有的注释,甚至解决方案,它对我的情况不起作用,但你的却起了作用。谢谢。你应该把这个答案标为正确答案