繁体   English   中英

create-react-app 后无法启动项目:错误:找不到模块“C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js”

[英]Unable to start project after create-react-app: Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'

我使用 npx create-react-app 创建了一个小型反应项目来处理一些反应教程,但我无法启动反应应用程序。 这是我尝试运行项目时遇到的错误:

> test-app@0.1.0 start C:\Users\pcname\Documents\React R&D\Pluralsight\test-app
> react-scripts start

'D\Pluralsight\test-app\node_modules\.bin\' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:983
  throw err;
  ^

Error: Cannot find module 'C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:980:15)
    at Function.Module._load (internal/modules/cjs/loader.js:862:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
    at internal/main/run_main_module.js:18:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! test-app@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the test-app@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\pcnmame\AppData\Roaming\npm-cache\_logs\2020-04-08T22_43_14_881Z-debug.log

我已经卸载了节点,重新安装了它。 全局而不是全局安装 react-scripts。 我已将 package.json 中的启动脚本替换为:

"start": "node node_modules/react-scripts/scripts/start.js"

那行得通。 我还在 app 文件夹中运行了 react-scripts start ,并且再次运行! 但是当我在应用程序文件夹中启动 npm 时,我无法让它工作

奖励:任何不使用 ASP NET Core 在 Visual Studio 中设置 React(不是 vs 代码)的教程将不胜感激。 我目前无法使用 VS 设置调试器。

使用create-react-app后可能会发生此错误,以防您的路径中有一些无效字符。

从你的路径中删除&

从此改变:

C:\Users\pcname\Documents\React R&D\Pluralsight\test-app

对此:

C:\Users\pcname\Documents\React RD\Pluralsight\test-app

它现在应该可以工作了!

重新运行npm i解决了我的问题。 我有同样的问题,原来“重新安装” npm 包摆脱了烦人

错误:找不到模块“C:\Users\pcname\Documents\react-scripts\bin\react-scripts.js”。 . . {代码:'MODULE_NOT_FOUND',requireStack:[]}

错误信息。

我正面临这个错误,谁能帮我解决这个问题!!!

您的环境已设置为使用 Node.js 17.9.0 (x64) 和 npm。

C:\Users\lpy> cd 桌面

C:\Users\lpy\Desktop>npx react-native init cws --version 0.68.2 node:internal/modules/cjs/loader:361 throw err; ^

错误:找不到模块“C:\Users\lpy\AppData\Local\npm-cache_npx\7930a8670f922cdb\node_modules\absolute-path\index.js”。 Please verify that the package.json has a valid "main" entry at tryPackage (node:internal/modules/cjs/loader:353:19) at Function.Module._findPath (node:internal/modules/cjs/loader:566: 18) 在 Function.Module._load (node:internal/modules/cjs/loader:778:27) 上 Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27) (node:internal/modules/cjs/loader:778:27) :internal/modules/cjs/loader:999:19) 在 Object 的 require (node:internal/modules/cjs/helpers:102:18) 处。 (C:\Users\lpy\AppData\Local\npm-cache_npx\7930a8670f922cdb\node_modules@react-native-community\cli\node_modules\metro-resolver\src\resolve.js:20:24) 在 Module._compile (node :internal/modules/cjs/loader:1099:14) 在 Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10) 在 Module.load (node:internal/modules/cjs/ loader:975:32) { 代码:'MODULE_NOT_FOUND',路径:'C:\Users\lpy\AppData\Local\npm-cache\_npx\7930a8670f922cdb\node_modules\absolute-path\package.json',requestPath:'absolute -小路' }

Node.js v17.9.0

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM