【问题标题】:Cannot Create React native first project using npx react-native init无法使用 npx react-native init 创建 React native 第一个项目
【发布时间】:2021-03-09 01:41:21
【问题描述】:

节点版本 v14.15.0 npm 版本 6.14.8

这是错误

$ npx react-native init Sjp
npm ERR! code ENOLOCAL
npm ERR! Could not install from "Ri\AppData\Roaming\npm-cache\_npx\19852" as it does not contain a package.json file.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Mi HI Ri\AppData\Roaming\npm-cache\_logs\2020-11-26T07_12_41_451Z-debug.log
Install for [ 'react-native@latest' ] failed with code 1

【问题讨论】:

    标签: react-native npm npx


    【解决方案1】:

    由于您的用户名 (Mi HI Ri) 中的空格而发生此错误,您可以通过执行以下步骤来解决它(在 Windows 上):

    1. 以管理员身份打开CMD然后进入C:\Users文件夹并输入命令:
    dir /x
    
    1. 您现在将看到一个项目列表,其中一行将具有用户名 (Mi HI Ri)。复制左边的文字,类似于MiHIRi~1(可能不同,请不要从这里复制)。
    2. 然后通过执行命令更新你的路径:
    // Replace MiHIRi~1 below with the text copied earlier
    npm config set cache "C:\Users\MiHIRi~1\AppData\Roaming\npm-cache" --global
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2022-10-04
      • 2018-12-13
      • 2022-07-30
      • 2021-09-25
      • 1970-01-01
      • 2020-10-19
      • 2022-06-22
      • 2020-10-28
      相关资源
      最近更新 更多