简体   繁体   English

npx create-react-app 获取错误

[英]npx create-react-app get error

I'm using:我正在使用:

Windows 10
npm -v 5.8.0
npx -v 9.7.1

When running npx , I'm getting: "The "path" argument must be of type string" .运行npx ,我得到: "The "path" argument must be of type string"

I am trying to create a React app.我正在尝试创建一个 React 应用程序。 Get this error:得到这个错误:

λ npx create-react-app myapp
npx: installed 1 in 4.576s

The "path" argument must be of type string
C:\Users\MyUser\AppData\Roaming\npm\node_modules\create-react-app\index.js
C:\Users\MyUser\AppData\Roaming\npm\node_modules\create-react-app\package.json: Unexpected string in JSON at position 52

This line in the error is important:错误中的这一行很重要:

C:\\Users\\MyUser\\AppData\\Roaming\\npm\\node_modules\\create-react-app\\package.json: Unexpected string in JSON at position 52 C:\\Users\\MyUser\\AppData\\Roaming\\npm\\node_modules\\create-react-app\\package.json:JSON 中的意外字符串在位置 52

That means that your package.json file is not formatted correctly.这意味着您的package.json文件格式不正确。

There are tools online such as this which can help ensure that the formatting of your package.json is correct.有在线工具,如可以帮助确保您的格式package.json是正确的。

resolved.解决。 Exist no one npx.不存在任何npx。 U must call npx with full path:你必须用完整路径调用 npx:

C:\\Users\\MyUser\\AppData\\Roaming\\npm\\npx.cmd create-react-app MyApp C:\\Users\\MyUser\\AppData\\Roaming\\npm\\npx.cmd create-react-app MyApp

Before running跑步前

npx create-react-app npx 创建反应应用程序

you need to install create-react-app globally on your machine using您需要使用以下命令在您的机器上全局安装 create-react-app

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

When this is successful, you can proceed to run the npx code as below成功后,您可以继续运行npx代码,如下所示

npx create-react-app app-name npx create-react-app 应用名称

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM