找回密码
 立即注册
查看: 5705|回复: 4

解决npm install 安装慢!!!

[复制链接]

334

主题

517

回帖

3394

积分

管理员

积分
3394
QQ
发表于 2023-6-9 00:27:24 | 显示全部楼层 |阅读模式
安装慢的原因
4 _, L) {6 @' V. M) X4 Bnpm install 默认使用的安装镜像是国外的镜像,😒😒
6 t5 n% l- f' H9 K) y所以在国内使用,会受到网络的限制,所以导致安装速度及其之慢,有的时候,会因为网速问题直接报错. D2 Z2 d4 r8 i+ w* c1 u
% J$ i% {- N/ u9 a/ T0 p( [
解决方式+ Q1 r  j4 ?; j& }( Z! o
方式一:更换npm的安装镜像源为国内的即可改变
4 b$ ?( o' b1 x/ n& p  P( K方式二:更换网络(一般不会这么做), [$ ?  P. g) f% V5 o) T

! j; v1 r$ `4 \- ^: I3 H' m【更换npm源】:
6 g1 T- r% W) V0 u1 s" }2 v" P4 d
npm config set registry https://registry.npm.taobao.org

$ {0 [) ]) q5 y' r0 N) m# M如果没有报错就是已经切换成功,然后我们再次执行 npm install
2 j# i) ], h! C, v6 q1 i* M或者我们可以在安装的时候指定其安装镜像
& C; Y) p2 z# ?+ S
$ N' @0 G" k: y; Y9 T
npm install --registry=https://registry.npm.taobao.org
3 x( s% Z8 ~' x% G8 P* `: T
最后 我们可以查看一下2 F% f4 q: a; V8 }
执行命令:% m5 B3 v0 B$ N. V& C

9 |0 O9 u& w9 D9 n; h: c
npm config get registry
回复

使用道具 举报

334

主题

517

回帖

3394

积分

管理员

积分
3394
QQ
 楼主| 发表于 2023-6-9 00:51:41 | 显示全部楼层
yarn安装依赖速度太慢的解决办法9 p8 z& T# a* O9 e) t3 b5 k$ ^
! K# G, b7 l* Q' ~4 b- E5 o
1、在用户目录文件夹下找到.yarnc文件(如我的是在:C:\Users\钟志胜\下)% |7 a# X7 v, j

4 K/ p/ M& e( B+ W' p; [3 U2、编辑.yarnc文件,添加如下内容
) ~7 z3 s; U2 T# G. `6 A( I: h
registry "https://registry.npm.taobao.org"
4 L% {* r$ R% r. S- echromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"
; ]1 p4 x: u3 ]3 a2 B) {. I) X; L2 G4 helectron_mirror "https://npm.taobao.org/mirrors/electron/"% L5 ^# \% _6 o. \/ @* {; g
lastUpdateCheck 1664005622411
$ Y- O" U# v5 ]8 T& aphantomjs_cdnurl "http://cnpmjs.org/downloads"
, x- w6 D8 |5 pprofiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
: T2 n8 w6 _* H: n- Ksass_binary_site "https://npm.taobao.org/mirrors/node-sass/"5 u! q( n8 I, F" S5 b! c
sqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"
( R" |8 O9 {; Q& C1 _+ |
3、编辑后保存文件
+ {* ]8 O9 F' `3 f8 n% b) S' |! J/ y+ ?% L7 _( I3 h& g4 M& N
4、设置为淘宝镜像+ r6 A# L) K9 z0 x
npm config set registry https://registry.npm.taobao.org/" i0 S# y* q5 |0 t" B! V% m
yarn config set registry https://registry.npm.taobao.org/
( I: }+ T9 X" N$ [, X. k

+ W5 N9 t4 N5 p+ Z7 ~' i8 `7 I5、查看当前镜像
3 E: t8 n/ t4 {, ~( O# [$ q
npm get registry 0 P$ E  Z& {7 \  c- m, n1 b- h
yarn config get registry
- A3 k* q6 ?; S: f( ~* y

4 [8 G" Z0 A; U6、把项目下的yarn.lock文件删除
* s5 q( z  v" V! m' p) S
8 u' [9 `4 ]6 |# d2 d) S, S7、重新执行yarn进行安装,速度有很大提升
/ @& y% }$ X/ W3 R
回复

使用道具 举报

334

主题

517

回帖

3394

积分

管理员

积分
3394
QQ
 楼主| 发表于 2023-6-9 01:08:09 | 显示全部楼层
npm安装任何包都报错的解决办法
! S3 i2 y0 L, k: V, X- l2 S+ ~% ^( r) _$ N$ R+ U  n" h" t
不知道什么原因,安装nodejs后,用npm安装任何东西都报错:
# {8 I& S2 \: Z5 d1 L
  1. C:\Users\Administrator>npm install express8 e5 j' H; |3 m5 J( ?. O
  2. npm ERR! Windows_NT 6.1.76014 E4 s: d) t& t+ O
  3. npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express"; J: N2 X# D9 m
  4. npm ERR! node v4.4.4
    " ]3 r  Q2 K; z# o, q  ?" [
  5. npm ERR! npm  v2.15.1" f7 p% p1 @5 M& ~  R2 H
  6. npm ERR! code ENOTFOUND6 J& M. j( _/ `2 d, \! q
  7. npm ERR! errno ENOTFOUND
    - U: e- L3 \/ ?. H2 _7 h' m5 C( S
  8. npm ERR! syscall getaddrinfo
    - A7 l4 ~$ z1 i
  9. , d' q: h. F0 y( P; Z# n
  10. npm ERR! network getaddrinfo ENOTFOUND xn--rvg xn--rvg:80
    ' r! p3 \" ^0 C
  11. npm ERR! network This is most likely not a problem with npm itself1 z9 B: b9 O: i, ~  d; Z
  12. npm ERR! network and is related to network connectivity.; O1 I( c7 ~* g
  13. npm ERR! network In most cases you are behind a proxy or have bad network settings.
      f/ K* S# q! e3 F
  14. npm ERR! network
    6 y9 y. C* I% D9 {0 K
  15. npm ERR! network If you are behind a proxy, please make sure that the$ o. Q: I6 x" ?9 Y: A
  16. npm ERR! network 'proxy' config is set properly.  See: 'npm help config'
    0 {, o$ a+ C0 y5 ]* G# ^* R  C- {
  17. 5 h7 A6 l8 b0 K5 {2 @3 T$ m
  18. npm ERR! Please include the following file with any support request:- C) e. m. J7 F. V/ U! L
  19. npm ERR!     C:\Users\Administrator\npm-debug.log
复制代码
6 c' W- w/ z$ s" D& ?- P+ W% q

- i( p( |5 `9 c8 h然后查npm的配置,也是一脸懵逼
5 R7 p9 ?; j8 Y' e5 o2 `& V1 z, \4 v* g, M* M! R$ D5 Q

  1. 8 ^9 Y8 {) A! Z" g/ @4 g5 f
  2. C:\Users\Administrator>npm config ls
    5 z7 U) X8 F0 Q# `4 [) E
  3. ; cli configs7 p5 Y+ R9 r/ {1 R* J
  4. user-agent = "npm/2.15.1 node/v4.4.4 win32 x64"# X. ]4 d  Z2 x% M  J
  5. 6 ^7 ?! k+ Q' M" {4 @, a$ M" C
  6. ; userconfig C:\Users\Administrator\.npmrc7 }) K5 Y. T1 e9 j8 N: {
  7. disturl = "https://npm.taobao.org/dist"
    / B) {/ @% |/ T& V  C
  8. proxy = "http://xn--rvg/"8 N: y" r9 L# w5 }* T* A1 j
  9. registry = "http://registry.npmjs.org/"1 p& W, a. t. d- O# k, o0 \
  10. strict-ssl = false
    : i0 X5 z# z, t7 ~7 a8 ^
  11. unsafe-perm = true- f; D% L. B9 \2 m' `
  12. 7 a7 F' t8 _( q
  13. ; builtin config undefined4 z. u' Y1 Z" E$ {, r
  14. cache = "C:\\Program Files\\nodejs\\node_global"" K/ ^! A9 {7 o4 ]5 E* |
  15. prefix = "C:\\Program Files\\nodejs\\node_global"% p  B0 H2 @% d' z4 b# O
  16. ( V# e4 W* W0 n
  17. ; node bin location = C:\Program Files\nodejs\node.exe4 ?; {/ _6 O: o, P: F& G7 ?' f
  18. ; cwd = C:\Users\Administrator
    / K* A, y6 F2 A
  19. ; HOME = C:\Users\Administrator+ M2 ^& b9 a  f# M* n
  20. ; 'npm config ls -l' to show all defaults.
复制代码

8 _# s& p0 t+ q9 h2 V' r7 o; w9 V3 W* R$ w" g8 {
根据网上的教程,换了N种镜像,问题依旧存在' r( b& G* P+ d; J' y& W
1 d0 ]4 i& C& i) |0 h0 Q
然后终于在网上找到个解决办法:5 t8 c6 C5 Y- j
: p* n) f& i) z6 h- m) B
  1. 解决办法:  g$ s) N. v" g

  2. , D' P3 b( \4 u& h  b. z6 x4 y
  3. 1、执行:
    : m, u: K1 Z; r5 A

  4. 1 F5 w# Q9 }$ P, l& [  {
  5. npm config get proxy9 `! f& L, W3 k- `' O4 c: y- F1 N
  6. npm config get https-proxy
    : D9 s1 G/ w' K( H. a
  7. 如果返回值不为null,继续执行:1 x4 L* `/ \) M. k
  8. (这一步很重要,一定要保证两个命令的返回值都为null,话说回来,应该出现这个错误这两个返回值有不为null的)7 j" A$ M0 a7 a- ]4 C) E% p
  9. npm config set proxy null- Q, e# ?) k8 X* n3 Z: F1 ?" w
  10. npm config set https-proxy null) ]# h4 k7 S( l9 }4 p
  11. 2、执行:7 k/ J& S' P& z1 O0 M3 y
  12. npm config set registry http://registry.cnpmjs.org/
复制代码

- G  c! Z/ a1 D8 G% e6 l* G9 V( M" K; {9 X
然后你就可以愉快的安装cnpm了
1 i) z0 k2 w  `8 B, _3 r6 W( B9 r( k
  1. npm install -g cnpm --registry=https://registry.npm.taobao.org
复制代码
0 s# @' M  i; `- b; L8 B  B$ i/ t
然后你就可以更加愉快的用cnpm安任何东西了
回复

使用道具 举报

334

主题

517

回帖

3394

积分

管理员

积分
3394
QQ
 楼主| 发表于 2023-6-9 01:33:03 | 显示全部楼层
解决使用yarn安装依赖出现“The engine "node" is incompatible with this module. Expected version "^14.18.0 || ^16.14.0 || >=18.0.0". Got "17.9.0"”的问题* L) c/ J0 x" x6 S
/ R! [2 v. `' a8 w# D" D
1、问题描述
" D# Y  t& i, f0 W) q8 u7 X* V, q/ U: G  ^1 y0 Q
某天在使用yarn安装依赖的时候,突然出现如下错误导致安装依赖终止:) `. u  G; v4 e: E2 B  y% z" g

( G" [7 U1 ]! V7 M5 ~9 A1 B* l
  1. The engine "node" is incompatible with this module. Expected version "^14.18.0 || ^16.14.0 || >=18.0.0". Got "17.9.0"
复制代码
; b6 o- b, q9 j: g5 n
2 R% R# b* J. [2 ]6 w/ f5 h* O& l
2、解决办法
% n2 z9 \9 P1 M( f* G使用如下命令忽略错误:
: V3 u" i% C' m# h; l* `% X
) E1 ]1 S! C5 {: syarn config set ignore-engines true
# q: s( o# [6 Y7 t
2 e" e; ]3 Q$ e1 ]然后再使用yarn进行安装即可
回复

使用道具 举报

334

主题

517

回帖

3394

积分

管理员

积分
3394
QQ
 楼主| 发表于 2023-6-9 03:02:21 | 显示全部楼层
  1. tyarn
    , D9 M0 \8 L7 X" p3 b! F$ f
  2. yarn install v1.22.19
    , J3 k3 |$ c6 Q7 z7 @0 v
  3. [1/4] Resolving packages...
    ( w6 U/ d; Q( w8 e3 b
  4. [2/4] Fetching packages...
    9 b* s" V3 p1 K5 r0 m
  5. [3/4] Linking dependencies...
    * V, _" m1 P9 Y7 b
  6. warning " > sass-loader@8.0.2" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
    0 n9 ?3 z2 L8 W" ^0 T& N
  7. [4/4] Building fresh packages...+ S* i! h: o' \' X5 q
  8. Done in 19.63s.9 C, U: |* g4 J  S( K
  9. PS D:\jsq\formG\form-generator-dev\form-generator-dev> npm run dev6 a7 P. z3 r3 f% B4 J" g
  10. ' Y9 i$ q% m" j1 X
  11. > form-generator@0.2.0 dev
      ^! b% x7 R" a" B( `1 o6 H
  12. > vue-cli-service serve
    0 r) j6 p) t. g0 k, q7 k1 D! V

  13. , u" r. v; r8 i8 C
  14. INFO  Starting development server...
    3 {; V( u0 `& R7 l
  15. 10% building 4/6 modules 2 active D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\hot\dev-server.jsError: error:0308010C:digital envelope routines::unsupported
    * B( ]( A. T" v* X5 I7 z$ C# {
  16.     at new Hash (node:internal/crypto/hash:71:19)' @" c3 T8 u& I* D1 C
  17.     at Object.createHash (node:crypto:133:10)
    " t* D' l5 k' d9 D0 o& y3 a
  18.     at module.exports (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\util\createHash.js:135:53)
    5 I$ @/ f+ b6 {0 K- L" N3 f8 G
  19.     at NormalModule._initBuildHash (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:417:16)3 C- z) E; T, [% h- T
  20.     at handleParseError (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:471:10)6 m3 r( }" s2 _3 [* o- h
  21.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:503:59 I8 L1 [7 l5 c2 K2 h; A
  22.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:358:123 r5 _( F1 ?; K* S& y( u1 H
  23.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:373:39 R* z; d* _# b  q  W
  24.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:214:10)0 N; J1 u3 [" ]$ `) I4 F
  25.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    / K3 Q2 S" U+ _
  26.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:236:3
    1 s; b- h+ S3 T% T8 M+ w; N
  27.     at runSyncOrAsync (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:130:11)# o- Q  |" N% b5 I- Z2 M1 T
  28.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:232:2)- c5 o5 _" R7 N6 {$ C* L0 j- M; B
  29.     at Array.<anonymous> (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    1 V' f6 n3 h* R* p& b
  30.     at Storage.finished (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)8 K% _4 l) ^. L1 Y/ [9 _$ D
  31.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:99 s. R# y6 K1 o, Y
  32. Error: error:0308010C:digital envelope routines::unsupported1 r3 y3 F5 n+ w8 f1 W; J
  33.     at new Hash (node:internal/crypto/hash:71:19)' [: H2 ^0 y. Q" N
  34.     at Object.createHash (node:crypto:133:10)
    $ c0 R; Q5 R, g) k! d
  35.     at module.exports (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\util\createHash.js:135:53)2 H* r: ^! g' g
  36.     at NormalModule._initBuildHash (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:417:16)! r/ I+ X" b# W3 X4 Y' H
  37.     at handleParseError (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:471:10)
    5 X& P" g5 D2 d0 Z- T
  38.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:503:5
    ( s$ P0 M4 X/ o1 ]& Y
  39.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:358:12
    ! u3 T  I+ [6 ], F* C! |( {9 ?
  40.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    / }! `# S, w2 ]% t: I' u
  41.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
      ?) U: ?3 Q( ^2 S  b' m
  42.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:221:10)( e! M2 Y( R, i/ {
  43.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:236:35 o2 R- }$ N8 [1 ^
  44.     at runSyncOrAsync (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:130:11)4 X; j$ J8 D) P3 u) F: t  F
  45.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:232:2)* Z4 O6 M5 M- L" b* E. ]
  46.     at Array.<anonymous> (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:205:4); F. Y. F& U7 B- |* _6 c
  47.     at Storage.finished (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    1 B9 C1 `8 p7 O; \3 o( m" b: S
  48.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9
    ( A7 _$ b. {4 N
  49. node:internal/crypto/hash:712 x& t% H) a& g, z0 O/ C& v& E4 P' @
  50.   this[kHandle] = new _Hash(algorithm, xofLen);' E. ?# F* X2 o# z
  51.                   ^+ o: `$ v  s  E& m" A/ R3 ?$ a
  52. ! L4 r, l0 E( K( t1 J
  53. Error: error:0308010C:digital envelope routines::unsupported
    8 ~. E" \& Y, |' {) o8 C; m
  54.     at new Hash (node:internal/crypto/hash:71:19)" z) D( _) l; b
  55.     at Object.createHash (node:crypto:133:10)2 b  h9 X7 l. ]( I6 }' B
  56.     at module.exports (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\util\createHash.js:135:53)
    ; O' M1 l; w* V
  57.     at NormalModule._initBuildHash (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:417:16)
    # D8 X7 p3 M9 M! x+ d* H0 q
  58.     at handleParseError (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:471:10)) Y0 c" w1 o. Q+ q
  59.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:503:5. q+ ^2 E2 c+ v; M# z; n
  60.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:358:12  t& w% u1 A, z
  61.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:373:3& U# a1 L, X, B+ F, x
  62.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    ) h1 A5 ?$ Q% {2 B3 o
  63.     at Array.<anonymous> (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:205:4)
    3 ?+ s# g( n9 c/ ~& g
  64.     at Storage.finished (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    7 u" M$ d1 {; B  r6 v+ }* O2 U
  65.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:96 T9 j  C$ m8 [' B5 }
  66.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\graceful-fs\graceful-fs.js:123:16
    8 H( I- g9 S. C9 d$ Q5 l( c
  67.     at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {/ Z  e: V5 d2 _+ H- e9 L0 }: X
  68.   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
    - W5 I( c9 G- b! ~- T
  69.   library: 'digital envelope routines',3 r5 V7 ^) Q& J9 ~9 c( `" r
  70.   reason: 'unsupported',7 Y! K! p% u& q! ?& `
  71.   code: 'ERR_OSSL_EVP_UNSUPPORTED'
    ! m- O' L+ A6 f5 F
  72. }
    - h& h4 m1 N1 y1 |: Y- U
  73. / R0 l$ |) ~; U' D0 H& a
  74. Node.js v18.16.0; n. r9 _& k; w4 X9 }( f$ {% y
  75. NativeCommandExitException: Program "npm.cmd" ended with non-zero exit code: 1.
复制代码

1 |9 q+ Y0 y: d8 H3 a* A' t
' E$ |* g9 x( Y& Y
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

QQ|Archiver|手机版|小黑屋|通达创业无忧 ( 粤ICP备2023021749号|粤公网安备 44030402006137号 )

GMT+8, 2025-11-29 23:56 , Processed in 0.073298 second(s), 3 queries , Redis On.

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

快速回复 返回顶部 返回列表