繁体   English   中英

在visual studio代码中安装react js时出错

[英]Getting error while Installing react js in visual studio code

我正在尝试使用链接https://code.visualstudio.com/docs/nodejs/reactjs-tutorial创建反应应用程序,但是当我运行命令时出现以下错误

创建反应应用程序我的应用程序

错误

Creating a new React app in C:\Users\thirunah\Documents\Visual Studio Code\my-app.

Installing packages. This might take a couple minutes.
Installing react, react-dom, and react-scripts...

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.0.17 (node_modules\react-scripts\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.0.17: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","ar
ch":"x64"})
npm ERR! Windows_NT 6.1.7601
npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "--save" "--save-exact" "
react" "react-dom" "react-scripts"
npm ERR! node v7.4.0
npm ERR! npm  v4.0.5
npm ERR! code E403

npm ERR! unregistered users are not allowed to access package @timer/detect-port : @timer/detect-port
npm ERR!
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

我有同样的错误,但是语法不同。
尝试使用cmd或VSCode终端,在C:\\Users\\thirunah创建您的react应用。 由于我认为尝试在较长的路径( C:\\Users\\thirunah\\Documents\\Visual Studio Code\\my-app )中创建C:\\Users\\thirunah\\Documents\\Visual Studio Code\\my-app App时存在问题。

因此,转到cmdC:\\Users\\thirunahcd C:\\Users\\thirunah )并编写

create-react-app Your-app-name

在此之前,请确保已安装nodecreate-react-app
您可以从node.js安装节点并在cmd编写

npm create-react-app -g

文档

npx create-react-app my-app
cd my-app
npm start

(npx随npm 5.2及更高版本一起提供,请参阅旧版npm的说明)

为什么 NPX create-react-app 在 VS Code 中失败?

当我尝试安装时

> npx create-react-app应用名称

我的 vscode 崩溃了,我无法安装整个。 它在会议中间崩溃。 所以原因可能是因为互联网连接速度慢。 超时设置为 30000 毫秒,默认为 30 秒。 尝试将超时增加到 60 秒,而不是将其添加到 create-react-app。 为此,请使用以下代码安装它:

> npx create-react-app应用名称-timeout=60000

对我来说,它再次崩溃,而不是“重新打开”vscode 选择“关闭”选项并再次打开它。 然后它将从停止的地方继续该过程。 这会将超时设置为 60 秒,这将提供足够的时间从 npm 注册表中为新的 React 应用程序获取所需的资源。 最后,您可以看到命令: Happy hacking! 😇

暂无
暂无

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

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