找不到模块'@babel/parser'

pdkcd3nj  于 2022-12-08  发布在  Babel
关注(0)|答案(4)|浏览(346)

当运行babel时,我无法再传输我的代码库。我做了。以前没有发生过这种情况,我也不知道为什么。这只发生在我拉远程主分支时,它有yarn.lock冲突。我用yarn命令解决了冲突。
这是我的package.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_modules并运行yarn install,但没有成功。

pxiryf3j

pxiryf3j1#

只需将babel-eslint8.2,3转换为10.0.1即可解决此问题

toiithl6

toiithl62#

对我来说,解决方案是删除 node_modules 文件夹,然后重新安装

rm -rf node_modules
yarn
oxf4rvwz

oxf4rvwz3#

这就是我的工作:
yarn add -D @babel/parser
NPM进行OR运算
npm i -D @babel/parser
祝你好运...

uurv41yg

uurv41yg4#

以下命令对我有效
npm审核修复--强制
请注意,审核修复程序将SemVer-major更新安装到顶级依赖项,而不仅仅是SemVer-compatible更新(https://docs.npmjs.com/cli/v7/commands/npm-audit

相关问题