安装了create-react-app而没有-g

Rah*_*dav 5 reactjs npm-install create-react-app

我安装create-react-app没有-g

C:\Users\user1\projects\react>npm install create-react-app

但是当我跑

C:\Users\user1\projects\react>create-react-app my-app1

我收到以下错误

'create-react-app' is not recognized as an internal or external command, operable program or batch file.

任何人都可以帮我理解-g旗帜的作用

如果我不想全局安装怎么办?

如何在没有全局安装的情况下使其工作?

Dan*_*mov 7

如果我不想全局安装怎么办?

如何在没有全局安装的情况下使其工作?

该软件包旨在全局安装.请按预期使用.

如果您不想永久安装它,在最近的Node版本中,您可以实际运行它而无需通过npx以下方式安装:

npx create-react-app my-app
Run Code Online (Sandbox Code Playgroud)

  • 提醒一下,您可以将[npx](https://www.npmjs.com/package/npx)作为单独的模块安装,以用于先前的节点版本 (2认同)

Siy*_*iya 3

如果您在本地安装了任何npm模块,它将存储在.bin里面的文件夹中node_modules。要使用它,您必须引用node_modules/.bin/the binary to run. 如果全局安装,模块的二进制文件将存储在操作系统存储从终端运行的可执行文件的任何位置,例如在 Unix/Linux 中,通常是这样的/usr/bin(不确定)。这就是为什么仅在终端中输入其名称就无法在本地安装某些内容的原因。而是绝对像这样参考它node_modules/bin/the binary to run。