创建react应用程序后,当我运行命令npm start
时,我会出现以下错误:
PS G:workspaceWEBgab-webclient> npm start
> client@0.1.0 start G:workspaceWEBgab-webclient
> react-scripts start
internal/modules/cjs/loader.js:628
throw e;
^
Error: No valid exports main found for 'G:workspaceWEBgab-webclientnode_modulespostcss-safe-parsernode_modulespostcss'
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:workspaceWEBgab-webclientnode_modulespostcss-safe-parserlibsafe-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:UsersgabriAppDataRoamingnpm-cache_logs2021-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 Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclenode-gyp-bin;G:workspaceWEBgab-webclientnode_modules.bin;C:Program Files (x86)Common FilesIntelShared Librariesredistintel64compiler;C:Program Files (x86)Common FilesOracleJavajavapath;C:Windowssystem32;C:Windows;C:WindowsSystem32Wbem;C:WindowsSystem32WindowsPowerShellv1.0;C:WindowsSystem32OpenSSH;C:Program Files (x86)NVIDIA CorporationPhysXCommon;C:Usersgabri.dnxbin;C:Program FilesMicrosoft DNXDnvm;C:Program FilesMicrosoft SQL Server130ToolsBinn;C:Program FilesNVIDIA CorporationNVIDIA NvDLISR;C:Program Filesdotnet;C:WINDOWSsystem32;C:WINDOWS;C:WINDOWSSystem32Wbem;C:WINDOWSSystem32WindowsPowerShellv1.0;C:WINDOWSSystem32OpenSSH;C:Program FilesJavajdk1.8.0_221bin;C:Program FilesWorldPainter;C:Program Filesnodejs;C:Program FilesGitcmd;C:UsersgabriAppDataLocalProgramsPythonPython38-32Scripts;C:UsersgabriAppDataLocalProgramsPythonPython38-32;C:UsersgabriAppDataLocalMicrosoftWindowsApps;C:UsersgabriAppDataRoamingDashlane6.1937.0.23352binFirefox_Extension{442718d9-475e-452a-b3e1-fb1ee16b8e9f}components;C:UsersgabriAppDataRoamingDashlane6.1937.0.23352ucrt;C:UsersgabriAppDataRoamingDashlane6.1937.0.23352binQt;C:UsersgabriAppDataRoamingDashlane6.1937.0.23352binSsl;C:UsersgabriAppDataRoamingnpm;D:workspaceffmpegbin;C:UsersgabriAppDataLocalatombin;C:UsersgabriAppDataLocalProgramsMicrosoft VS Codebin;C:UsersgabriAppDataLocalMicrosoftWindowsApps;C:UsersgabriAppDataLocalGitHubDesktopbin
9 verbose lifecycle client@0.1.0~start: CWD: G:workspaceWEBgab-webclient
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 Filesnodejsnode_modulesnpmnode_modulesnpm-lifecycleindex.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:321:20)
13 verbose stack at ChildProcess.<anonymous> (C:Program Filesnodejsnode_modulesnpmnode_modulesnpm-lifecyclelibspawn.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:workspaceWEBgab-webclient
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 ]
尝试将您的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
我在系统上安装node js时遇到了这个问题,所以我尝试更改node js&它有效。。。
更改的目的地:-
C: \JAVA\
每当您遇到此类问题时,找不到与您的文件路径相关的解决方案是因为当您启动一个项目时,您停止了,当您想返回到此类项目时。许多开发人员往往忘记了他们需要将目录更改为他们创建的应用程序。例如,让我说这个应用程序的名称是clean应用程序,你已经清除了你的服务器,要在使用npm启动之前返回到这样的项目,你需要cd到目录中,否则它会一直说";[]模块未找到";在我想起我必须Cd到文件中之前,这种情况发生过几次,所以为了解决这些问题,你Cd到应用程序的名称中,然后你键入npm start,当你克隆某人的项目时,可能人的主文件和启动文件不同,尝试检查主文件,并将主文件的名称更改为package.json中启动文件的名称。谢谢
清除依赖项并重试:
npm cache clear --force
rm -rf node_modules
npm install
信用:https://stackoverflow.com/a/70120799/2415632
我遇到了同样的问题,我只是删除了tsconfig.js
文件并重新启动了npm start
。问题解决了。