尝试在Windows 10上安装React时出错

时间:2020-04-30 14:54:50

标签: reactjs windows npm create-react-app

我正在尝试使用npm install -g create-react-app在Windows 10上安装React。

安装失败,并且出现以下错误消息:

错误:EINVAL:参数无效,mkdir'C:\ Program Files \ Git \'C:\ Users \ User \ AppData \ Roaming \ npm''

我应该提到的是,在我收到此错误之前,我已经在Windows机器上安装了nodejs 12.16.3 LTS版本。

有人知道这是为什么吗,或者是否有解决此问题的方法?

请帮助!

1 个答案:

答案 0 :(得分:0)

首先,您没有尝试安装react。您正在尝试安装create-react-app终端工具。使用该工具,您可以轻松创建反应项目。

让我们先做一些检查。


# Remove if you have installed it before
npm uninstall -g create-react-app

# Check if you have installed 'git' (if not install git)
git --version

# Check node.js (if not install node.js)
node --version


# Check npm  (if not install npm)
npm --version


如果已全部安装,则现在可以开始安装create-react-app。我不是Windows用户,但我建议您使用Powershell。在Linux上,我将使用sudo命令进行此安装。


# install create-react-app
npm install -g create-react-app

# check if it is installed
create-react-app --version