【发布时间】:2022-02-10 21:42:32
【问题描述】:
我关注了 reactjs.org 网站的 create-react-app 到一个 T
我无法在任何地方找到这个特定的错误,而且大多数帖子都是几年前的; 无论如何与帖子中的具体错误无关。
有没有人遇到过这种情况,你做了什么来解决它?
最新版本的 Win10,如果有帮助的话。 Node.js的LTS版本v16.14.0
我的 Node.js 安装只是在操作系统驱动器上的一个干净的 express 安装。有什么想法吗?
运行npx create-react-app my-app后,错误消息如下:
C:\Users\Keith & Vanny>npx create-react-app myapp
'Vanny\AppData\Local\npm-cache\_npx\c67e74de0542c87c\node_modules\.bin\' is not recognized as
an internal or external command,
operable program or batch file.
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'C:\Users\create-react-app\index.js'
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:77:12)
at node:internal/main/run_main_module:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
更新:我通过npm i create-react-app在本地安装它并尝试使用npm init react-app my-app创建。
它们都产生上述相同的错误。我认为这与运行批处理脚本的错误的 unrecognized command 部分有关,它无法解析和完成工作,然后没有安装包。所以 javascript 行话告诉我我缺少必需的包;我的paths for Node 是完美的。 清理安装并清理所有软件包。这让我很困惑。 看来如果我们不能解决这个问题,我会去找开发人员。
【问题讨论】:
-
你的节点是什么版本?
-
@HritikSharma LTS 版本 v16.14.0
-
我会仔细检查您是否无意中安装了
create-react-app。 The CRA docs 有检查说明。 -
@ReedDunkle 该节点安装在以前没有安装节点本身的机器上。根据 reactjs 站点,您甚至不需要通过 npm 安装软件包。单线 npx 命令可以即时完成所有这些工作。我的机器上没有 npm install create-react-app。
-
@KeithCronin 是的,他们希望你仔细检查你没有安装它,因为
npx处理它。不过,听起来这不是问题。不幸的是,我没有任何其他想法。