gpt4 book ai didi

javascript - 如何在 Windows PhpStorm 中安装和使用 Babel 和 watchers?

转载 作者:搜寻专家 更新时间:2023-10-31 23:37:33 26 4
gpt4 key购买 nike

我已经从 https://nodejs.org/en/ 下载了 nodejs (v6.3.0 Current)并安装它。

我还在 PhpStorm 中安装了 nodejs 插件。

enter image description here

在我的设置 → 语言和框架 → Node.js 和 NPM 我可以看到它的设置

enter image description here

在 PhpStorm 的终端中,我正在输入命令:

npm install --save-dev babel

我在我的项目中看到 node_modulesbabel.js

enter image description here

我也在设置 → 语言和框架 → Node.js → 包中看到它

现在我正在将 Npm 包路径从 C:\Program Files\nodejs\node_modules\npm 更改为 myProjectDir/node_modules(在我的例子中是 D:\!work\!WEBServers\OpenServer\domains\dev.test.ru\node_modules)。我不知道为什么..我需要这样做吗?

我正在用代码创建 js 文件:

let foo = () => console.log('test');
foo();

并尝试添加观察者

enter image description here

但是当我尝试更改文件中的某些内容时 - PhpStorm 给我一个错误:

An exception occurred while executing watcher 'Babel'. Watcher has been disabled. Fix it.: Cannot run program "D:!work!WEBServers\OpenServer\domains\dev.test.ru\node_modules\.bin\babel" (in directory "D:!work!WEBServers\OpenServer\domains\dev.test.ru\src"): CreateProcess error=193, %1 is not a valid win32 application


我做错了什么?如何安装 node、babel 和其他扩展(gulp、grunt 等)并启用观察者?我应该做什么设置?

最佳答案

作为@LazyOne 在comments说:试试 babel.cmd 而不是 babel

我试过了,它成功了。

就这么简单>_<


所以,我的设置是:

程序 - D:!work!WEBServers\OpenServer\domains\dev.test.ru\node_modules\.bin\babel(或 $FileParentDir$\node_modules\.bin\babel .cmd 带有宏)

参数 - --presets es2015 $FileDir$/test.js --out-file $FileParentDir$/out/test.js

工作目录 - $FileParentDir$\src

enter image description here


Arguments 为整个文件夹启用watcher 是:

--presets es2015 $FileDir$ -d $FileParentDir$/out

关于javascript - 如何在 Windows PhpStorm 中安装和使用 Babel 和 watchers?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38486453/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com