【问题标题】:Getting error while Installing react js in visual studio code在 Visual Studio 代码中安装 React js 时出错
【发布时间】:2017-06-13 10:59:30
【问题描述】:

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

create-react-app 我的应用

错误

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>

【问题讨论】:

  • 你看过this question吗?
  • 是的。我检查了我的注册表,它和上面提到的一样。
  • 您是否在管理命令 shell 中运行? (这可能会有所帮助)。
  • 是的,我在管理 cmd 中运行

标签: node.js reactjs visual-studio-code npm-install


【解决方案1】:

我遇到了同样的错误,但是语法不同。
尝试使用cmd 或 VSCode 终端,在C:\Users\thirunah 中创建您的反应应用程序。因为我认为尝试在长路径中创建 React 应用程序时存在问题 (C:\Users\thirunah\Documents\Visual Studio Code\my-app)。

所以去cmdC:\Users\thirunahcd C:\Users\thirunah)写

create-react-app Your-app-name

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

npm create-react-app -g

【讨论】:

  • 欢迎堆栈溢出 Ahmed,感谢您的贡献。我可以建议您this page 以熟悉问答中使用的格式吗?
【解决方案2】:

来自docs

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

(npx 随附于 npm 5.2+ 及更高版本,请参阅旧版 npm 的说明 版本)

【讨论】:

    【解决方案3】:

    为什么 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! ?

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2012-08-14
      • 2017-04-04
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多