![](/img/trans.png)
[英]Can I run index.html with React without npm start and npx create-react-app?
[英]why i can not create a new react app with npm?
我打算用 npm 創建一個新的 React 應用程序,但它不起作用,而且我每次嘗試都會遇到太多錯誤,有人可以幫助我嗎?:(
我在 cmd 中輸入了這一行
npx create-react-app my-app
和錯誤:
npm ERR! code ECONNRESET
npm ERR! syscall read
npm ERR! errno -4077
npm ERR! network read ECONNRESET
npm ERR! network This is a problem related to network connectivity.
npm ERR! network In most cases you are behind a proxy or have bad network settings.
npm ERR! network
npm ERR! network If you are behind a proxy, please make sure that the
npm ERR! network 'proxy' config is set properly. See: 'npm help config'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\sobha\AppData\Local\npm-cache\_logs\2022-11-29T11_57_33_191Z-debug-0.log
Aborting installation.
npm install --no-audit --save --save-exact --loglevel error react react-dom react-scripts cra-template has failed.
Deleting generated file... node_modules
Deleting generated file... package.json
Deleting my-app/ from C:\Users\sobha\Desktop\react
Done.
首先檢查您的網絡連接,然后
npm cache clean --force
npm create react-app
問題很可能是您被 ISP 或公司的防火牆/代理阻止訪問該網站。 使用上述方法更快更容易,但它也不安全,因為它無法驗證您連接到正確的網站。 要檢查您是否被阻止,只需在瀏覽器中輸入 go 至 registry.npmjs.org。 你應該得到一些文本回來。
選項1
嘗試這個:
npm config set registry http://registry.npmjs.org/
因此 npm 請求 http url 而不是 https。
然后嘗試相同的npx create-react-app my-app
命令。
選項 2
您可能還想檢查您的 NPM 代理設置並可能將其刪除。
npm config get proxy
npm config rm proxy
npm config rm https-proxy
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.