首页 > 解决方案 > Windows 10 上的 React Native:npm install from mac 项目创建命令未找到问题

问题描述

我在尝试使用'npm install'命令安装反应本机节点模块时遇到奇怪的问题,该项目在mac机器上运行良好,但是当我在windows 10上运行它时;它最终出现错误消息,指出该命令失败为“。” (点)命令无法识别。

这是调试失败片段。我非常感谢任何人指导我解决这个问题。非常感谢。

2092 info run react-native-router-flux@4.0.6 postinstall node_modules/react-native-router-flux ./node_modules/.bin/opencollective postinstall
2093 info run react-native-router-flux@4.0.6 postinstall { code: 1, signal: null }
2094 info run native-base@2.12.1 postinstall { code: 0, signal: null }
2095 timing build:run:postinstall:node_modules/native-base Completed in 146ms
2096 timing reify:rollback:createSparse Completed in 4215ms
2097 timing reify:rollback:retireShallow Completed in 0ms
2098 timing command:install Completed in 37508ms
2099 verbose stack Error: command failed
2099 verbose stack     at ChildProcess.<anonymous> (C:\Users\NAV\AppData\Roaming\npm\node_modules\npm\node_modules\@npmcli\promise-spawn\index.js:64:27)
2099 verbose stack     at ChildProcess.emit (node:events:390:28)
2099 verbose stack     at maybeClose (node:internal/child_process:1064:16)
2099 verbose stack     at Process.ChildProcess._handle.onexit (node:internal/child_process:301:5)
2100 verbose pkgid react-native-router-flux@4.0.6
2101 verbose cwd E:\BFC-Caterer\bfc-caterer
2102 verbose Windows_NT 10.0.19042
2103 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Users\\NAV\\AppData\\Roaming\\npm\\node_modules\\npm\\bin\\npm-cli.js" "i"
2104 verbose node v16.10.0
2105 verbose npm  v7.24.1
2106 error code 1
2107 error path E:\BFC-Caterer\bfc-caterer\node_modules\react-native-router-flux
2108 error command failed
2109 error command C:\Windows\system32\cmd.exe /d /s /c ./node_modules/.bin/opencollective postinstall
2110 error '.' is not recognized as an internal or external command,
2110 error operable program or batch file.
2111 verbose exit 1

标签: react-nativenpm

解决方案


首先,您是否在 Windows 系统上安装了节点?如果您不确定进入 cmd 并运行:

node -v

它应该为您提供一个版本,如果没有,请转到https://nodejs.org/en/download/并下载 Node.js 并安装它,然后再次进入 cmd 并运行上述命令。

这 '。' 不被识别为内部或外部命令错误通常与计算机找不到您要求启动的程序有关。转到 C:\Windows\system32\ 以查看程序“cmd.exe”是否确实存在,如果存在则转到您的环境变量并查看是否有路径:C:\Windows\system32\cmd .exe /d /s /c ./node_modules/.bin/opencollective。如果不添加它并尝试再次启动您的项目。


推荐阅读