有人能帮我安装React吗?我犯了一个奇怪的错误



经过几天的努力、搜索StackOverflow和阅读教程,我被react安装卡住了。我正在一步一步地分享我所做的事情。

节点版本为14.15.3。

运行npx create-react-app blog,结果是:

`Creating a new React app in C:My GarbageHtml & CSSReact.jsblog.
Installing packages. This might take a couple of minutes.
Installing react, react-dom, and react-scripts with cra-template...


> core-js@2.6.12 postinstall C:My GarbageHtml & CSSReact.jsblognode_modulesbabel-runtimenode_modulescore-js
> node -e "try{require('./postinstall')}catch(e){}"

> core-js@3.8.1 postinstall C:My GarbageHtml & CSSReact.jsblognode_modulescore-js
> node -e "try{require('./postinstall')}catch(e){}"

> core-js-pure@3.8.1 postinstall C:My GarbageHtml & CSSReact.jsblognode_modulescore-js-pure
> node -e "try{require('./postinstall')}catch(e){}"

> ejs@2.7.4 postinstall C:My GarbageHtml & CSSReact.jsblognode_modulesejs
> node ./postinstall.js
+ react@17.0.1
+ react-scripts@4.0.1
+ cra-template@1.1.1
+ react-dom@17.0.1
added 1903 packages from 721 contributors and audited 1907 packages in 116.704s
124 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities

Initialized a git repository.
Installing template dependencies using npm...
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_moduleschokidarnode_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.2.1 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.2.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_moduleswatchpack-chokidar2node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_moduleswebpack-dev-servernode_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
+ @testing-library/jest-dom@5.11.6
+ web-vitals@0.2.4
+ @testing-library/user-event@12.6.0
+ @testing-library/react@11.2.2
added 29 packages from 77 contributors and audited 1936 packages in 10.711s
124 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities
Removing template package using npm...
npm WARN tsutils@3.17.1 requires a peer of typescript@>=2.8.0 || >= 3.2.0-dev || >= 3.3.0-dev || >= 3.4.0-dev || >= 3.5.0-dev || >= 3.6.0-dev || >= 3.6.0-beta || >= 3.7.0-dev || >= 3.7.0-beta but none is installed. You must install peer dependencies yourself.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.2.1 (node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.2.1: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_moduleswatchpack-chokidar2node_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@2.1.3 (node_moduleschokidarnode_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.13 (node_moduleswebpack-dev-servernode_modulesfsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.13: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})
removed 1 package and audited 1935 packages in 6.56s
124 packages are looking for funding
run `npm fund` for details
found 0 vulnerabilities

Created git commit.
Success! Created blog at C:My GarbageHtml & CSSReact.jsblog
Inside that directory, you can run several commands:
npm start
Starts the development server.
npm run build
Bundles the app into static files for production.
npm test
Starts the test runner.
npm run eject
Removes this tool and copies build dependencies, configuration files
and scripts into the app directory. If you do this, you can’t go back!
We suggest that you begin by typing:
cd blog
npm start
Happy hacking!`

cd blog

现在,在运行npm start时,我得到了这个错误:

$ npm start
> blog@0.1.0 start C:My GarbageHtml & CSSReact.jsblog
> react-scripts start
'CSSReact.jsblognode_modules.bin' is not recognized as an internal or external command,
operable program or batch file.
internal/modules/cjs/loader.js:883
throw err;
^
Error: Cannot find module 'C:My Garbagereact-scriptsbinreact-scripts.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! blog@0.1.0 start: `react-scripts start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the blog@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:UsersJYOTIRMOYAppDataRoamingnpm-cache_logs2020-12-29T10_59_15_177Z-debug.log```
Hoping for your valuable help :)

我建议您在项目中使用更多的"正常"路径。计算机不喜欢空间,但已经学会了处理它们。但是&在你的路径上签名会破坏命令。Bash将其解释为blog@0.1.0 start C:My GarbageHtml&CSSReact.jsblog,这就是为什么它告诉您它找不到'CSS\React.js\blog\node_modules…'

修复它的最简单方法是将文件夹重命名为不带&

相关内容

最新更新