无法验证babel我正在尝试创建的文件。?

时间:2018-04-05 13:15:53

标签: javascript reactjs babel yarnpkg

我尝试安装React和babel。

C:\Users\Desktop\React Course Projects\Indecision App>babel src\app.js --out-file=public/scripts\app.js --presets=env,react

我收到以下错误。

Error: ENOENT: no such file or directory, open 'C:\Users\Desktop\React Course Projects\Indecision App\public\scripts\app.js'
at Object.fs.openSync (fs.js:646:18)
at Object.fs.writeFileSync (fs.js:1299:33)
at output (C:\Users\AppData\Local\Yarn\Data\global\node_modules\babel-cli\lib\babel\file.js:90:10)
at walk (C:\Users\AppData\Local\Yarn\Data\global\node_modules\babel-cli\lib\babel\file.js:150:5)
at files (C:\Users\AppData\Local\Yarn\Data\global\node_modules\babel-cli\lib\babel\file.js:156:7)
at module.exports (C:\Users\AppData\Local\Yarn\Data\global\node_modules\babel-cli\lib\babel\file.js:184:5)
at Object.<anonymous> (C:\Users\AppData\Local\Yarn\Data\global\node_modules\babel-cli\lib\babel\index.js:129:1)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)

我在我的系统中安装了Babel和yarn

babel -V
6.24.1 (babel-core 6.26.0)

yarn -v
1.5.1

关于我犯的错误,我应该知道些什么吗?

1 个答案:

答案 0 :(得分:0)

Babel的--out-file选项will not create the target folder for you if it doesn't already exist

有两个解决方案:

  • 在运行Babel
  • 之前创建public/scripts文件夹
  • 使用--out-dir=public/scripts代替--out-file=public/scripts/app.js创建目录(如果该目录尚不存在)。