javascript React Native npx react-app问题

k5ifujac  于 11个月前  发布在  Java
关注(0)|答案(2)|浏览(131)

我的PowerShell(终端)警告,我不使用npm安装或任何一个刚刚尝试npx的npx-react-app NKE命令:

PS C:\Users\berk.BERK-PC\React Native> npx create-react-app NKE                                                                                                                                              
npm WARN using --force Recommended protections disabled.
npm WARN using --force Recommended protections disabled.
npm ERR! code ENOENT
npm ERR! syscall lstat
npm ERR! path C:\Users\berk.BERK-PC\React Native\'~
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, lstat 'C:\Users\berk.BERK-PC\React Native\'~'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\berk.BERK-PC\AppData\Local\npm-cache\_logs\2023-12-28T21_08_04_536Z-debug-0.log
PS C:\Users\berk.BERK-PC\React Native>

字符串
Loc文件:

0 verbose cli C:\Program Files\nodejs\node.exe C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js
1 info using [email protected]
2 info using [email protected]
3 timing npm:load:whichnode Completed in 1ms
4 timing config:load:defaults Completed in 2ms
5 timing config:load:file:C:\Program Files\nodejs\node_modules\npm\npmrc Completed in 3ms
6 timing config:load:builtin Completed in 3ms
7 timing config:load:cli Completed in 1ms
8 timing config:load:env Completed in 0ms
9 timing config:load:file:C:\Users\berk.BERK-PC\React Native\.npmrc Completed in 0ms
10 timing config:load:project Completed in 1ms
11 timing config:load:file:C:\Users\berk.BERK-PC\.npmrc Completed in 1ms
12 timing config:load:user Completed in 1ms
13 timing config:load:file:C:\Users\berk.BERK-PC\React Native\'~\.npm-global'\etc\npmrc Completed in 0ms
14 timing config:load:global Completed in 0ms
15 timing config:load:setEnvs Completed in 1ms
16 timing config:load Completed in 9ms
17 timing npm:load:configload Completed in 9ms
18 timing config:load:flatten Completed in 1ms
19 timing npm:load:mkdirpcache Completed in 1ms
20 timing npm:load:mkdirplogs Completed in 0ms
21 verbose title npm exec create-react-app NKE
22 verbose argv "exec" "--" "create-react-app" "NKE"
23 timing npm:load:setTitle Completed in 0ms
24 timing npm:load:display Completed in 1ms
25 verbose logfile logs-max:10 dir:C:\Users\berk.BERK-PC\AppData\Local\npm-cache\_logs\2023-12-28T21_08_04_536Z-
26 verbose logfile C:\Users\berk.BERK-PC\AppData\Local\npm-cache\_logs\2023-12-28T21_08_04_536Z-debug-0.log
27 timing npm:load:logFile Completed in 7ms
28 timing npm:load:timers Completed in 0ms
29 timing npm:load:configScope Completed in 0ms
30 warn using --force Recommended protections disabled.
31 timing npm:load Completed in 39ms
32 silly logfile start cleaning logs, removing 7 files
33 timing arborist:ctor Completed in 0ms
34 silly logfile done cleaning log files
35 http fetch GET 200 https://registry.npmjs.org/create-react-app 306ms (cache revalidated)
36 timing arborist:ctor Completed in 0ms
37 timing command:exec Completed in 325ms
38 verbose stack Error: ENOENT: no such file or directory, lstat 'C:\Users\berk.BERK-PC\React Native\'~'
39 verbose cwd C:\Users\berk.BERK-PC\React Native
40 verbose Windows_NT 10.0.22621
41 verbose node v20.10.0
42 verbose npm  v10.2.3
43 error code ENOENT
44 error syscall lstat
45 error path C:\Users\berk.BERK-PC\React Native\'~
46 error errno -4058
47 error enoent ENOENT: no such file or directory, lstat 'C:\Users\berk.BERK-PC\React Native\'~'
48 error enoent This is related to npm not being able to find a file.
48 error enoent
49 verbose exit -4058
50 timing npm Completed in 673ms
51 verbose code -4058
52 error A complete log of this run can be found in: C:\Users\berk.BERK-PC\AppData\Local\npm-cache\_logs\2023-12-28T21_08_04_536Z-debug-0.log


我需要创建一个应用程序,我该如何解决这个问题,有人可以帮助我吗?我安装了节点,我在系统环境变量中添加,但不工作。

1l5u6lss

1l5u6lss1#

为了在Windows中创建react-native应用程序,请按照以下步骤操作:
如果你是react-native的新手,那么我建议你去react-native页面安装,因为他们会给予你简单的安装方法=> https://reactnative.dev/docs/environment-setup
下面是一个简化版本:
1.学习如何安装npm包管理器或node js相关依赖项

  1. lean有哪些react-naive依赖项
    下面是另一个安装指南一步一步:
    1.安装Node.js
  • 安装Python
  • 由于React Native依赖Python 2,但建议使用Python 3。从官方网站下载并安装Python:
  • install JDK
  • React Native需要安装Java。您可以从Oracle官方网站下载并安装JDK
  • 安装Yarn(可选):Yarn是一个包管理器,可以作为npm的替代品。你可以按照他们网站上的说明安装Yarn:
  • 设置环境变量:
  • 将Node.js和Yarn添加到系统的PATH变量中。
  • 安装React native CLI:
  • 使用终端安装
npm install -g react-native-cli

字符串

  • 创建一个新的React native项目
npx react-native init <your-project-name>

5kgi1eie

5kgi1eie2#

如果你是react-native的新手,那么我建议你选择expo(expo是react-native的顶级,它让开发者的生活变得简单)。
以下是世博会的解释:

  • Expo是一个免费的开源框架,用于使用React Native构建原生移动的应用程序。它提供了一组工具和服务,简化了开发过程,允许开发人员在不需要广泛的原生开发知识的情况下构建移动的应用程序。

关于react-native https://reactnative.dev/docs/environment-setup的更多详情,请查看结帐文档。
现在我们来讨论一个解决方案

  • 请检查你是否安装了node.js,npm:
node -v 
npm -v

字符串

  • 如果他们面临任何错误,那么你的环境变量可能没有设置。
  • 通过运行以下命令清除npm缓存
npm cache clean --force

  • 再次尝试安装react-native项目
npx react-native init <project-name>

相关问题