【发布时间】:2017-11-18 18:04:58
【问题描述】:
我正在尝试按照文档建议安装flow https://flow.org/en/docs/install/ 它需要安装babel-cli 才能运行babel。
我使用下面的命令https://babeljs.io/docs/usage/cli/安装了babel-cli
npm install --save-dev babel-cli
> npm install --save-dev babel-cli
todo-app@0.1.0 D:\React JS\todo-app
`-- babel-cli@6.24.1
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@^1.0.0 (node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.0.17 (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN enoent ENOENT: no such file or directory, open 'D:\React JS\todo-app\node_modules\acorn-dynamic-import\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'D:\React JS\todo-app\node_modules\create-hmac\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'D:\React JS\todo-app\node_modules\create-hash\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'D:\React JS\todo-app\node_modules\diffie-hellman\package.json'
npm WARN enoent ENOENT: no such file or directory, open 'D:\React JS\todo-app\node_modules\pbkdf2\package.json'
package.json
{
"name": "todo-app",
"version": "0.1.0",
"private": true,
"dependencies": {
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-redux": "^5.0.5",
"react-tap-event-plugin": "^2.0.1",
"redux": "^3.6.0"
},
"devDependencies": {
"babel-cli": "^6.24.1",
"react-scripts": "1.0.7",
"redux-devtools": "^3.4.0",
"webpack": "^2.6.1"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test --env=jsdom",
"eject": "react-scripts eject"
}
}
当我运行babel 命令时,它给了我一个错误“babel”不是内部或外部命令、可运行程序或批处理文件。
更新
这是因为“可能找不到本地二进制文件,因为本地 ./node_modules/.bin 不在 $PATH 中” - 但是您认为在 $PATH 中添加所有项目的 node_modules/.bin 是否好?或者有什么替代方法吗?
PS:我在windows机器上。
【问题讨论】:
-
哪个操作系统?尝试全局安装?
npm install --global babel-cli -
@mkaatman 我正在 Windows 上尝试,babeljs.io/docs/usage/cli docs 说“你不应该全局安装它”
-
是的,但你在 Windows 上。所有赌注都取消了。
-
@mkaatman babel 在 Windows 上不起作用?
-
试试:
./node_modules/.bin/babel
标签: javascript babeljs flowtype