开始使用babel-cli

时间:2016-01-25 11:05:15

标签: javascript node.js npm babeljs

我无法按照getting started guide安装babel-cli。

npm install --save-dev babel-cli

fsevents@1.0.6 install /[path]/node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents \> node-pre-gyp install --fallback-to-build [fsevents] Success: "/[path]/node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents/lib/binding/Release/node-v43-darwin-x64/fse.node" is installed via remote babel-cli@6.4.5 node_modules/babel-cli ├── slash@1.0.0 ├── log-symbols@1.0.2 ├── path-exists@1.0.0 ├── path-is-absolute@1.0.0 ├── fs-readdir-recursive@0.1.2 ├── convert-source-map@1.1.3 ├── v8flags@2.0.11 (user-home@1.1.1) ├── output-file-sync@1.1.1 (xtend@4.0.1, mkdirp@0.5.1) ├── commander@2.9.0 (graceful-readlink@1.0.1) ├── chalk@1.1.1 (escape-string-regexp@1.0.4, supports-color@2.0.0, ansi-styles@2.1.0, has-ansi@2.0.0, strip-ansi@3.0.0) ├── source-map@0.5.3 ├── glob@5.0.15 (inherits@2.0.1, once@1.3.3, inflight@1.0.4, minimatch@3.0.0) ├── babel-core@6.4.5 (shebang-regex@1.0.0, babel-template@6.3.13, babel-messages@6.3.18, babel-helpers@6.4.5, private@0.1.6, debug@2.2.0, babylon@6.4.5, babel-types@6.4.5, minimatch@2.0.10, babel-code-frame@6.3.13, babel-generator@6.4.5, babel-traverse@6.4.5, json5@0.4.0) ├── request@2.67.0 (is-typedarray@1.0.0, aws-sign2@0.6.0, forever-agent@0.6.1, caseless@0.11.0, stringstream@0.0.5, tunnel-agent@0.4.2, oauth-sign@0.8.0, isstream@0.1.2, json-stringify-safe@5.0.1, extend@3.0.0, node-uuid@1.4.7, combined-stream@1.0.5, qs@5.2.0, tough-cookie@2.2.1, mime-types@2.1.9, form-data@1.0.0-rc3, bl@1.0.1, hawk@3.1.3, http-signature@1.1.0, har-validator@2.0.6) ├── lodash@3.10.1 ├── bin-version-check@2.1.0 (minimist@1.2.0, semver-truncate@1.1.0, semver@4.3.6, bin-version@1.0.4) ├── babel-polyfill@6.3.14 (babel-regenerator-runtime@6.3.13, core-js@1.2.6) ├── babel-register@6.4.3 (home-or-tmp@1.0.0, mkdirp@0.5.1, source-map-support@0.2.10, core-js@1.2.6) ├── babel-runtime@5.8.35 (core-js@1.2.6) └── chokidar@1.4.2 (inherits@2.0.1, glob-parent@2.0.0, async-each@0.1.6, is-binary-path@1.0.1, is-glob@2.0.1, readdirp@2.0.0, anymatch@1.3.0, fsevents@1.0.6)

因此安装似乎成功,但是当我尝试时:

/> which babel babel not found

1 个答案:

答案 0 :(得分:3)

修改

这是2018年,您可能想要使用yarn babelnpx babel(取决于您是否使用纱线或npm)来运行本地安装的babel-cli。 It is very uncommon now to install babel-cli globally。出于历史原因,我将在下面保留最初的答案。

好像你想要使用babel gloablly。然后使用-g标志

npm install -g babel-cli

如果您想在本地使用babel-cli,请使用

./node_modules/.bin/babel

有关详细信息,请参阅第3节“使用情况”中的babel usage guide