我在新建 React 應用程式時(執行npx create-react-app my-app命令后)遇到這個問題:
? YN0000: ┌ Resolution step
node:internal/process/promises:246
triggerUncaughtException(err, true /* fromPromise */);
^
_r [RequestError]: read ECONNRESET
at ClientRequest.<anonymous> (/home/aldaspan/.yarn/releases/yarn-3.1.1.cjs:154:14361)
at Object.onceWrapper (node:events:510:26)
at ClientRequest.emit (node:events:402:35)
at ClientRequest.o.emit (/home/aldaspan/.yarn/releases/yarn-3.1.1.cjs:149:59453)
at TLSSocket.socketErrorListener (node:_http_client:447:9)
at TLSSocket.emit (node:events:390:28)
at emitErrorNT (node:internal/streams/destroy:164:8)
at emitErrorCloseNT (node:internal/streams/destroy:129:3)
at processTicksAndRejections (node:internal/process/task_queues:83:21)
at TLSWrap.onStreamRead (node:internal/stream_base_commons:211:20) {
code: 'ECONNRESET',
timings: {
start: 1639471914529,
socket: 1639471914529,
lookup: 1639471914530,
connect: 1639471922067,
secureConnect: undefined,
upload: undefined,
response: undefined,
end: undefined,
error: 1639471922468,
abort: undefined,
phases: {
wait: 0,
dns: 1,
tcp: 7537,
tls: undefined,
request: undefined,
firstByte: undefined,
download: undefined,
total: 7939
}
}
}
Node.js v17.2.0
Aborting installation.
yarnpkg add --exact react react-dom react-scripts cra-template --cwd /home/aldaspan/galog/react-shop has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.
作業系統:Ubuntu 21.10,Node -v:v17.2.0,nodejs --version:v12.22.5,npm -v:8.1.4
我是 React 的新手,這個問題我已經找了好幾天了,但我還沒有找到真正的解決方案。
降低Node( sudo n 16.13.1)版本后,提示其他錯誤:
YN0000: Done with warnings in 5m 4s
node:internal/modules/cjs/loader:936
throw err;
^
Error: Cannot find module 'react-scripts/scripts/init.js'
Require stack:
- /home/aldaspan/react-shop/[eval]
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at [eval]:2:20
at Script.runInThisContext (node:vm:129:12)
at Object.runInThisContext (node:vm:305:38)
at node:internal/process/execution:75:19
at [eval]-wrapper:6:22
at evalScript (node:internal/process/execution:74:60) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/aldaspan/react-shop/[eval]' ]
}
Aborting installation.
node has failed.
Deleting generated file... package.json
Deleting generated file... yarn.lock
Done.
uj5u.com熱心網友回復:
- 您應該使用推薦的node版本,目前是
16. 為此,您可以使用n模塊:
// if you haven't istalled before
npm install n -g
//to have the latest stable version
n stable
// if one of them do not pass, may be should be using sudo, like so :
sudo npm install n -g
sudo n stable
- 如果您已全域安裝
create-react-app(因為我們現在使用npx,所以您不應該安裝),您需要像這樣洗掉它:
npm uninstall -g create-react-app
// or with yarn like so :
yarn global remove create-react-app
- 然后洗掉您嘗試創建的專案并重新開始:
npx create-react-app my-ap
轉載請註明出處,本文鏈接:https://www.uj5u.com/houduan/381325.html
標籤:节点.js 反应 新产品经理 创建反应应用程序 npx
上一篇:Vuejs。更新時更新資料()
