Vis*_*ati 2 node.js npm reactjs create-react-app
我的系统上安装了 Node(v6.10.3) 和 npm(3.10.10)。我安装create-react-app了它,它成功了。但是,当我尝试通过简单地运行在我的机器上创建一个新项目时:create-react-app sample-app,它给了我以下错误:
create-react-app :术语“create-react-app”不被识别为 cmdlet、函数、脚本文件或可运行程序的名称。检查名称的拼写,或者如果包含路径,请验证路径是否正确,然后重试。在 line:1 char:1 + create-react-app + ~~~~~~~~~~~~~~~~ + CategoryInfo : ObjectNotFound: (create-react-app:String) [], CommandNotFoundException +fullyQualifiedErrorId : CommandNotFoundException
多年来一直在使用 cli,从未遇到过这种情况。有人知道为什么会发生这种情况吗?是否与 npm/node 的版本有关?
小智 12
您应该create-react-app使用-g.
npm install -g create-react-app
Run Code Online (Sandbox Code Playgroud)
或者,您可以跳过create-react-app. 为此,您首先需要更新到较新版本的 nodejs 和 npm,然后才能运行。
npx create-react-app yourappname
Run Code Online (Sandbox Code Playgroud)