【问题标题】:React error with create-react-app command使用 create-react-app 命令反应错误
【发布时间】:2018-08-26 11:05:08
【问题描述】:

我在 Windows 10 上通过命令行创建 React 应用程序时遇到了奇怪的情况。运行 create-react-app 命令时出现以下错误。我正在使用节点 v8.9.4 和 npm v6.4.0。

Creating a new React app in D:\react\myreactapp. 

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

npm ERR! Unexpected end of JSON input while parsing near '...^1.0.1","line-numbers' 

npm ERR! A complete log of this run can be found in: 
npm ERR! C:\Users\USER\AppData\Roaming\npm-cache\_logs\2018-08-26T11_04_03_908Z-debug.log 

Aborting installation. 
npm install --save --save-exact --loglevel error react react-dom react-scripts has failed. 

Deleting generated file... package.json 
Deleting myreactapp / from D:\react 
Done.

【问题讨论】:

  • 运行 react-native info 并使用结果编辑问题。

标签: reactjs npm cmd


【解决方案1】:

这可能与您给它的项目名称有关。尝试使用dragon-case,即只有小写和连字符。所以不是

$ create-react-native-app myApp 

使用

$ create-react-native-app my-app

或者从错误消息中,可能是在应用程序名称 (myreactapp) 之后添加了一个空格,然后在再次按 Enter 之前按了反斜杠而不是 Enter?

另外,试试:npm cache clean --force

如果这不起作用:yarn cache clean

这可能是由于自述文件中的 React-Native 安装说明中缺少换行符(此后已修复),在 npm installnpm start 之间导致用户执行 npm install npm start - 这是安装 @ 987654329@ 本身及其所有测试。请参阅问题:https://github.com/facebook/react-native/issues/20015

无论如何,如果您运行react-native info 并告诉我们结果会很好。

【讨论】:

    猜你喜欢
    • 2022-06-14
    • 2018-11-26
    • 2020-04-19
    • 1970-01-01
    • 2021-04-28
    • 1970-01-01
    • 2020-08-11
    • 2016-12-09
    • 2020-10-31
    相关资源
    最近更新 更多