簡體   English   中英

'npm start' 上的 React.JS 應用 MODULE_NOT_FOUND 錯誤

[英]React.JS App MODULE_NOT_FOUND error on 'npm start'

我對 React.js 有疑問。

創建反應應用程序后,當我運行命令npm start出現以下錯誤:

PS G:\workspace\WEB\gab-web\client> npm start

> client@0.1.0 start G:\workspace\WEB\gab-web\client
> react-scripts start

internal/modules/cjs/loader.js:628
  throw e;
  ^

Error: No valid exports main found for 'G:\workspace\WEB\gab-web\client\node_modules\postcss-safe-parser\node_modules\postcss'
    at resolveExportsTarget (internal/modules/cjs/loader.js:625:9)
    at applyExports (internal/modules/cjs/loader.js:502:14)
    at resolveExports (internal/modules/cjs/loader.js:551:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:657:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:960:27)
    at Function.Module._load (internal/modules/cjs/loader.js:855:27)
    at Module.require (internal/modules/cjs/loader.js:1033:19)
    at require (internal/modules/cjs/helpers.js:72:18)
    at Object.<anonymous> (G:\workspace\WEB\gab-web\client\node_modules\postcss-safe-parser\lib\safe-parse.js:1:17)
    at Module._compile (internal/modules/cjs/loader.js:1144:30) {
  code: 'MODULE_NOT_FOUND'
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! client@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the client@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\gabri\AppData\Roaming\npm-cache\_logs\2021-01-10T19_26_53_509Z-debug.log

這是完整的日志文件:

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli   'start'
1 verbose cli ]
2 info using npm@6.13.4
3 info using node@v13.6.0
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle client@0.1.0~prestart: client@0.1.0
6 info lifecycle client@0.1.0~start: client@0.1.0
7 verbose lifecycle client@0.1.0~start: unsafe-perm in lifecycle true
8 verbose lifecycle client@0.1.0~start: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;G:\workspace\WEB\gab-web\client\node_modules\.bin;C:\Program Files (x86)\Common Files\Intel\Shared Libraries\redist\intel64\compiler;C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\Users\gabri\.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\130\Tools\Binn\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files\dotnet\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Java\jdk1.8.0_221\bin;C:\Program Files\WorldPainter;C:\Program Files\nodejs\;C:\Program Files\Git\cmd;C:\Users\gabri\AppData\Local\Programs\Python\Python38-32\Scripts\;C:\Users\gabri\AppData\Local\Programs\Python\Python38-32\;C:\Users\gabri\AppData\Local\Microsoft\WindowsApps;C:\Users\gabri\AppData\Roaming\Dashlane\6.1937.0.23352\bin\Firefox_Extension\{442718d9-475e-452a-b3e1-fb1ee16b8e9f}\components;C:\Users\gabri\AppData\Roaming\Dashlane\6.1937.0.23352\ucrt;C:\Users\gabri\AppData\Roaming\Dashlane\6.1937.0.23352\bin\Qt;C:\Users\gabri\AppData\Roaming\Dashlane\6.1937.0.23352\bin\Ssl;C:\Users\gabri\AppData\Roaming\npm;D:\workspace\ffmpeg\bin;C:\Users\gabri\AppData\Local\atom\bin;C:\Users\gabri\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\gabri\AppData\Local\Microsoft\WindowsApps;C:\Users\gabri\AppData\Local\GitHubDesktop\bin
9 verbose lifecycle client@0.1.0~start: CWD: G:\workspace\WEB\gab-web\client
10 silly lifecycle client@0.1.0~start: Args: [ '/d /s /c', 'react-scripts start' ]
11 silly lifecycle client@0.1.0~start: Returned: code: 1  signal: null
12 info lifecycle client@0.1.0~start: Failed to exec start script
13 verbose stack Error: client@0.1.0 start: `react-scripts start`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:321:20)
13 verbose stack     at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:321:20)
13 verbose stack     at maybeClose (internal/child_process.js:1028:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:286:5)
14 verbose pkgid client@0.1.0
15 verbose cwd G:\workspace\WEB\gab-web\client
16 verbose Windows_NT 10.0.19042
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "start"
18 verbose node v13.6.0
19 verbose npm  v6.13.4
20 error code ELIFECYCLE
21 error errno 1
22 error client@0.1.0 start: `react-scripts start`
22 error Exit status 1
23 error Failed at the client@0.1.0 start script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

我嘗試了一些在互聯網上找到的東西,但仍然沒有找到解決我的問題的方法。 謝謝;p

嘗試將您的 npm 升級到 v14.5 或更高版本,同時全局刪除react-create-app

npm uninstall -g create-react-app

然后嘗試重新創建您的項目:

npx create-react-app myapp

這是一個已知問題,學分: https://github.com/facebook/create-react-app/issues/9273#issuecomment-654182223

我在我的系統上安裝節點 js 時遇到了這個問題,所以我嘗試更改節點 js 的目錄(文件安裝)並且它可以工作......

更改目的地:-

C:\JAVA\

每當您遇到此類問題時,找不到與您的文件路徑相關的解決方案是因為當您啟動項目並停止時,以及當您想要 go 回到此類項目時。 許多開發人員往往忘記他們需要將目錄更改為他們創建的應用程序。 例如,在使用 npm 啟動之前,我說應用程序的名稱是 clean-app 並且您已經清除了服務器並將 go 返回到此類項目,您需要 cd 進入目錄,否則它將繼續顯示“[]找不到模塊”,這發生在我身上幾次,然后我才想起我必須 Cd 進入文件,所以要解決這些問題,你 cd 進入應用程序的名稱,然后鍵入 npm start 和當你克隆某人的項目時並且可能個人主文件和啟動文件不同,請嘗試檢查主文件並將主文件的名稱更改為 package.json 中的啟動文件的名稱。 謝謝

我也是編程新手。 我遇到了同樣的問題,我只是刪除了 tsconfig.js 文件並重新啟動了 npm 啟動。 問題解決了。 也許這對其他有同樣問題的人有幫助。 謝謝。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM