尝试使用Intellij设置Filewatcher,以便将ES6与Babel转换器一起使用。我已经按照他们的指南here,这似乎安装得很好,除了当我尝试编写javascript代码并执行转换器代码时,我收到此错误:
Error: Couldn't find preset "es2015" relative to directory "/Volumes/ShanStore/Main/Projects/NewWebsite"
at /Users/Shan/node_modules/babel-core/lib/transformation/file/options/option-manager.js:281:17
at Array.map (native)
at OptionManager.resolvePresets (/Users/Shan/node_modules/babel-core/lib/transformation/file/options/option-manager.js:265:20)
at OptionManager.mergePresets (/Users/Shan/node_modules/babel-core/lib/transformation/file/options/option-manager.js:254:10)
at OptionManager.mergeOptions (/Users/Shan/node_modules/babel-core/lib/transformation/file/options/option-manager.js:239:14)
at OptionManager.init (/Users/Shan/node_modules/babel-core/lib/transformation/file/options/option-manager.js:338:12)
at File.initOptions (/Users/Shan/node_modules/babel-core/lib/transformation/file/index.js:216:65)
at new File (/Users/Shan/node_modules/babel-core/lib/transformation/file/index.js:137:24)
at Pipeline.transform (/Users/Shan/node_modules/babel-core/lib/transformation/pipeline.js:46:16)
at transform (/Users/Shan/node_modules/babel-cli/lib/babel/util.js:50:22)
我安装了Node v6.4.0
和npm 3.10.3
。我的根目录中有一个名为.babelrc
的文件,如此 -
NewWebsite
|_ .babelrc
|_ index.html
|_ script.js
我运行这些命令来安装与babel相关的东西:
sudo npm install --save-dev babel-cli
sudo npm install --save-dev babel-preset-es2015
我的.babelrc
文件如下所示:
{
"presets": ["es2015"]
}
我在这里搜索了各种解决方案,但没有一个能够奏效。我不知道这里有什么问题!有什么帮助吗?