在终端安装nvm时报错,错误信息如下👇
curl: (7) Failed to connect to raw.githubusercontent.com port 443 after 10 ms: Connection refused
问题原因
因为🧱,需要科学上网,但是实际上我挂着VPN依旧报错,
DNS污染
解决方案参考:SwitchHosts配置host
下载SwitchHosts;
新建local文件,并将下面内容粘贴进去:
199.232.68.133 raw.githubusercontent.com
199.232.68.133 user-images.githubusercontent.com
199.232.68.133 avatars2.githubusercontent.com
199.232.68.133 avatars1.githubusercontent.com
点击文件左侧的开关键,进行激活;
重新进入终端,输入命令
错误日报(二) 问题描述在终端利用npx创建react项目my-app的时候,运行下面的代码👇
npx create-react-app my-app
但是报错,报错内容如下👇
node:internal/modules/cjs/loader:942
throw err;
^
Error: Cannot find module 'block-stream'
Require stack:
- /Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/lib/entry-writer.js
- /Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/lib/pack.js
- /Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/tar.js
- /Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/index.js
- /Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app/createReactApp.js
- /Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:939:15)
at Module._load (node:internal/modules/cjs/loader:780:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object. (/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/lib/entry-writer.js:7:19)
at Module._compile (node:internal/modules/cjs/loader:1105:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Module._load (node:internal/modules/cjs/loader:827:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/lib/entry-writer.js',
'/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/lib/pack.js',
'/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/node_modules/tar/tar.js',
'/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/tar-pack/index.js',
'/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app/createReactApp.js',
'/Users/apple/.npm/_npx/c67e74de0542c87c/node_modules/create-react-app/index.js'
]
}
Node.js v18.1.0
问题原因
失败原因位置,尝试了下面几种方案,但是依旧不起作用:
尝试一:利用npm初始化;结果:失败;
npm init react-app my-app
尝试二:卸载以前可能下载的react项目,再重新下载;结果:失败;
解决方案参考react官方方案利用yarn代替npx,使用如下👇命令
yarn create react-app my-app
结果:成功安装react项目my-app;
进一步:
在终端输入yarn start
,自动打开浏览器进入http://localhost:3000
到达创建的项目页面;
yarn test
yarn build
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)