【发布时间】:2018-10-11 17:14:47
【问题描述】:
在运行 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,但没有成功。
【问题讨论】:
-
您是否删除了锁定的包 json 文件?
-
这可能是个愚蠢的问题,但为什么不
yarn add @babel/parser? -
@JoeFitzsimmons 我没有。我检查了
yarn.lock和@babel/parser确实存在 -
@ChrisG babel/parser 是 babel/core 中的一个依赖项,我不应该或直接在我的项目中安装它。
-
@ChrisG,我检查了所有的 cmets 甚至解决方案,但它不适用于我的情况,但你的情况可以。谢谢。
标签: javascript npm babeljs