NodeJS “npm启动”时出现React.JS应用程序模块未找到错误

n3schb8v  于 2022-11-03  发布在  Node.js
关注(0)|答案(4)|浏览(168)

我对React.js有问题。
创建react应用程序后,当我运行命令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 ]

我试了一些在网上找到的东西,但仍然没有找到一个解决我的问题的方法。有害物

oknwwptz

oknwwptz1#

尝试将您的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

xyhw6mcr

xyhw6mcr2#

我在我的系统上安装 NodeJS 时遇到过这个问题,所以我试着为 NodeJS 更改目录(文件安装)&它工作正常...
已更改的目标:-
C:\JAVA\

qni6mghb

qni6mghb3#

每当你面临这样的问题,解决方案与您的文件路径找不到是因为当你开始一个项目,你停止,当你想回到这样的项目。许多开发人员往往忘记他们需要改变目录到他们创建的应用程序。例如,让我说的应用程序的名称是干净的-应用程序,您已经清除了您的服务器,并返回到使用npm开始之前的此类项目,你需要cd到目录,否则它会一直声明“[]模块找不到”,这种情况发生在我身上几次之前,我记得我必须Cd到文件,因此,要解决此类问题,您可以cd输入应用程序的名称,然后键入npm start。当您克隆某人的项目时,可能此人的主文件和启动文件不同,请尝试检查主文件,并将主文件的名称更改为package.json中的启动文件的名称。谢谢

eufgjt7s

eufgjt7s4#

我也是编程新手。我遇到了同样的问题,我只是简单地删除了tsconfig.js文件并重新启动了npm start。问题解决了。也许这对其他遇到同样问题的人会有帮助。谢谢。

相关问题