我正在使用“入门”指南,因为到目前为止,在遵循教程时,我在尝试创建 React 应用程序时遇到了无数错误。
我马上就遇到了问题。当我运行 npx create-react-app my-app
时,我得到以下信息:
Cannot find module 'C:\Users\Aristophanes\node_modules\create-react-app\index.js'
谁能告诉我我做错了什么?谢谢。
最佳答案
这一定是与你的 Node 安装有关的问题(也许你手动删除了 create-react-app 包?)。我建议执行以下步骤:
- 卸载 Node 和 npm
- 删除计算机中的 npm 缓存和 npm 模块(在 Windows 计算机中,您通常可以在 C:\Users\{username}\AppData\Roaming\npm-cache 和 C:\Users\{user name}\AppData\Roaming\npm) 分别。
- 再次安装node和npm
如果您确实不想删除 node 和 npm,请尝试步骤 2 并查看是否有效。按照这些步骤完成了我的工作,希望对您有所帮助。
关于node.js - 创建 React 应用程序入门 - "Cannot find module",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/56150309/