尝试使用 Intellij 设置 Filewatcher,以便将 ES6 与 Babel 转译器一起使用。我在这里遵循了他们的指南,除了当我尝试编写 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
有一个文件,如下所示——</p>.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"]
}
我在这里搜索了各种解决方案,但都没有奏效。我不知道这里有什么问题!有什么帮助吗?