[英]Cannot find module '@babel/parser'
I am no longer able to transpile my codebase when running babel
.运行
babel
时,我不再能够转换我的代码库。 I made.我做了。 It wasn't happening before and I am unable to figure out why.
以前没有发生过,我无法弄清楚为什么。 This only happened when I pulled remote master branch, which had
yarn.lock
conflicts.这只发生在我拉远程 master 分支时,它有
yarn.lock
冲突。 I resolved conflicts with the yarn
commands.我解决了与
yarn
命令的冲突。
here is part of my package.json
这是我的
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",
...
}
}
Running babel src -d build
results in the following error运行
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' }
I also tried deleting node_modules
and run yarn install
with no luck.我还尝试删除
node_modules
并运行yarn install
,但没有成功。
能够通过简单地将babel-eslint
从8.2,3
到10.0.1
来解决该问题
This is what worked for me:这对我有用:
yarn add -D @babel/parser
OR with NPM
或与
NPM
npm i -D @babel/parser
Good Luck...祝你好运...
Below command worked for me以下命令对我有用
npm audit fix --force npm 审计修复 --force
Please note that audit fix install SemVer-major updates to toplevel dependencies, not just SemVer-compatible ones ( https://docs.npmjs.com/cli/v7/commands/npm-audit )请注意,审计修复将 SemVer 主要更新安装到顶级依赖项,而不仅仅是 SemVer 兼容的更新 ( https://docs.npmjs.com/cli/v7/commands/npm-audit )
For me the solution was to delete the node_modules folder, and reinstall对我来说,解决方案是删除node_modules文件夹,然后重新安装
rm -rf node_modules
yarn
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.