首页 > 解决方案 > `npm create-react-app` 命令不适用于 npm 版本 6.9.0

问题描述

我之前已经成功使用过 create-react-app ,但现在由于某种原因它无法正常工作。我做了以下

npm install -g create-react-app
npm create-react-app test

但是出现了以下内容

Usage: npm <command>

where <command> is one of:
    access, adduser, audit, bin, bugs, c, cache, ci, cit,
    clean-install, clean-install-test, completion, config,
    create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
    edit, explore, get, help, help-search, hook, i, init,
    install, install-ci-test, install-test, it, link, list, ln,
    login, logout, ls, org, outdated, owner, pack, ping, prefix,
    profile, prune, publish, rb, rebuild, repo, restart, root,
    run, run-script, s, se, search, set, shrinkwrap, star,
    stars, start, stop, t, team, test, token, tst, un,
    uninstall, unpublish, unstar, up, update, v, version, view,
    whoami

npm <command> -h  quick help on <command>
npm -l            display full usage info
npm help <term>   search for help on <term>
npm help npm      involved overview

Specify configs in the ini-formatted file:
    C:\Users\xxxxx\.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config

npm@6.9.0 C:\Program Files\nodejs\node_modules\npm

有谁知道发生了什么?

编辑:我成功了

 npx create-react-app test

但是,如果您知道为什么 npm 不起作用,请提供帮助

标签: npmcreate-react-app

解决方案


npx附带npm 5.2+ 和更高版本,使用npx create-react-app test你使用的,它工作!在第一种情况下,对于npm 5.1 或更早版本,您不能使用npx,您应该使用create-react-app test而不使用npm

您也可以使用更高版本的相同命令,npm应该没问题

这应该test在您所在的目录中创建应用程序。

如果你想使用npm,你可以做npm init react-app test


推荐阅读