[英]Cannot find module '@babel/parser'
運行babel
時,我不再能夠轉換我的代碼庫。 我做了。 以前沒有發生過,我無法弄清楚為什么。 這只發生在我拉遠程 master 分支時,它有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
,但沒有成功。
能夠通過簡單地將babel-eslint
從8.2,3
到10.0.1
來解決該問題
這對我有用:
yarn add -D @babel/parser
或與NPM
npm i -D @babel/parser
祝你好運...
以下命令對我有用
npm 審計修復 --force
請注意,審計修復將 SemVer 主要更新安裝到頂級依賴項,而不僅僅是 SemVer 兼容的更新 ( https://docs.npmjs.com/cli/v7/commands/npm-audit )
對我來說,解決方案是刪除node_modules文件夾,然后重新安裝
rm -rf node_modules
yarn
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.