【发布时间】:2016-07-12 08:18:17
【问题描述】:
我有一个这样的目录结构:
> build
> node_modules
> webpack.config.js
> .babelrc
> .gitignore
我的.babelrc 看起来像这样:
{
"presets": ["es2015", "stage-0", "react"]
}
目前我收到以下错误...
Module build failed: Error: Couldn't find preset "es2015" relative to directory
.babelrc 文件中是否有任何选项可以让我指定 node_modules 的路径?或者有什么其他方法可以解决这个问题?
- 很遗憾,无法将 node_modules 移至根目录。
【问题讨论】:
-
你已经安装了预设?如果没有,请在控制台上使用
npm install babel-preset-es2015 --save -
是的,如果 node_modules 文件夹位于根级别,则安装了所有工作,但我的问题是,这不是一个选项,有什么想法吗?
-
@Jai 我在同一条船上,你找到解决方案了吗?
-
@GaryChang 恐怕不会 :( 最后我们不得不更改文件夹结构。如果你能找到解决办法,我很想听听!
-
@Jai,是的,我解决了这个问题,至少对我自己而言。我已经发布了答案。
标签: javascript npm webpack babeljs