繁体   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