簡體   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