【问题标题】:unable to verify babel for the file I'm trying to create.?无法验证我要创建的文件的 babel。?
【发布时间】:2018-04-05 13:15:52
【问题描述】:

我尝试安装 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

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

【问题讨论】:

    标签: javascript reactjs babeljs yarnpkg


    【解决方案1】:

    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,如果该目录不存在,创建该目录。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-05-19
      • 1970-01-01
      相关资源
      最近更新 更多