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

解决npm install 安装慢!!!

[复制链接]

314

主题

478

回帖

2960

积分

管理员

积分
2960
QQ
发表于 2023-6-9 00:27:24 | 显示全部楼层 |阅读模式
安装慢的原因
  ^  j$ u( O2 O7 D& B& [5 i4 Ynpm install 默认使用的安装镜像是国外的镜像,😒😒+ i  m  D; O7 I# {) \
所以在国内使用,会受到网络的限制,所以导致安装速度及其之慢,有的时候,会因为网速问题直接报错8 m" W5 q6 R5 u( o" [
1 U0 z% |8 z) u. }
解决方式7 y( f$ p, E' v6 ]' h9 G# N) S; l3 m
方式一:更换npm的安装镜像源为国内的即可改变0 w  m+ o# g0 ~" q2 `
方式二:更换网络(一般不会这么做)
/ M* f- F3 A+ B  `) w
: T# C, ]4 i. i/ z【更换npm源】:
; [7 X! h& ?; Z9 O2 A4 V' f6 z# Z! L
npm config set registry https://registry.npm.taobao.org

$ x# w! |/ v( F6 ]如果没有报错就是已经切换成功,然后我们再次执行 npm install
8 \9 |' N. N3 K# u$ ?或者我们可以在安装的时候指定其安装镜像
/ `  h# F, z0 m5 o; ~3 u0 N1 {
! W3 r" g* c& k9 O" }  T+ P
npm install --registry=https://registry.npm.taobao.org

+ g2 E* ^: p  `5 K  {/ C/ f最后 我们可以查看一下0 p) s9 Z7 f& [6 t; Y" i
执行命令:0 }$ B7 u# M: _

8 k  K0 \# j1 a+ V4 D- n
npm config get registry
回复

使用道具 举报

314

主题

478

回帖

2960

积分

管理员

积分
2960
QQ
 楼主| 发表于 2023-6-9 00:51:41 | 显示全部楼层
yarn安装依赖速度太慢的解决办法' c- J* Y0 U1 |. ^1 p" i8 B

. ?, T8 I/ S; y! S4 H) F1、在用户目录文件夹下找到.yarnc文件(如我的是在:C:\Users\钟志胜\下)
' X# d2 R" r3 N# [) C- t  Z) @' ^0 Y3 ?$ q! j! f, r1 Y% [
2、编辑.yarnc文件,添加如下内容
, {8 n8 c' m9 O* s$ v! Z5 c" g) G8 p
registry "https://registry.npm.taobao.org"& X7 l' D1 Z9 s! A
chromedriver_cdnurl "https://cdn.npm.taobao.org/dist/chromedriver"  y4 O2 l: J; H2 I& X  D3 j$ h
electron_mirror "https://npm.taobao.org/mirrors/electron/"
: y; b( Y4 O/ n+ f5 PlastUpdateCheck 1664005622411" ~8 `4 _2 U; L% G+ ]  \9 p' T
phantomjs_cdnurl "http://cnpmjs.org/downloads"2 y+ s- U" Q# Y$ \' k  `
profiler_binary_host_mirror "https://npm.taobao.org/mirrors/node-inspector/"
: @6 k8 _4 G7 r$ P) ^sass_binary_site "https://npm.taobao.org/mirrors/node-sass/"
2 C, G( u: I: _* N" W7 G% O5 esqlite3_binary_host_mirror "https://foxgis.oss-cn-shanghai.aliyuncs.com/"

+ U! f" [4 T. c3、编辑后保存文件
0 K. s- ^/ t! [: @8 h  c. Z
) z- U/ i% ]' Q2 R4、设置为淘宝镜像9 z1 k1 H% S2 ^5 X( W
npm config set registry https://registry.npm.taobao.org/
) ]. a3 |& F) ?' Kyarn config set registry https://registry.npm.taobao.org/
3 Z. j( B+ G+ @

; f1 ^9 d) |3 ^5、查看当前镜像% S& ?) N( K) F% u+ q4 A+ G5 @
npm get registry 5 t% S) F  j) A* J; b( {0 l( i
yarn config get registry
$ Z; f: s+ ^* O2 o

4 b( A# w" [6 b7 q! `6、把项目下的yarn.lock文件删除! V. W! U: A% s; S1 p" d! ^
  H8 J1 e# j8 C5 `" K5 L9 H4 B! a/ m
7、重新执行yarn进行安装,速度有很大提升
1 i$ t* _/ ]1 t, F3 F9 k# W
回复

使用道具 举报

314

主题

478

回帖

2960

积分

管理员

积分
2960
QQ
 楼主| 发表于 2023-6-9 01:08:09 | 显示全部楼层
npm安装任何包都报错的解决办法; G& l+ p1 V8 c7 A6 X0 m. o

0 b8 e3 W) |) L, u7 G8 k5 S& D不知道什么原因,安装nodejs后,用npm安装任何东西都报错:
8 n+ `& m6 {  ^0 w( n% d4 G
  1. C:\Users\Administrator>npm install express
    . m5 x/ I) N5 B" n/ W  y1 l
  2. npm ERR! Windows_NT 6.1.7601
    2 ~0 n, D) z, ^! u  V# d# \: w! r
  3. npm ERR! argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "express"0 z0 q: M& w8 D# G* u- B/ d
  4. npm ERR! node v4.4.4
    ; Q9 H% |0 A  o& U' N0 S: [, }- F
  5. npm ERR! npm  v2.15.1
    3 s1 ?& Z7 R0 }( P, t% M/ v( h
  6. npm ERR! code ENOTFOUND4 D4 ]6 E% y3 f& s: I" K- r
  7. npm ERR! errno ENOTFOUND6 R) u' H1 t- m+ x
  8. npm ERR! syscall getaddrinfo5 K+ a' z* U  ?& t* v$ k+ i
  9. . M* P: h+ r! t" A4 q! }
  10. npm ERR! network getaddrinfo ENOTFOUND xn--rvg xn--rvg:80) C+ C0 q8 ?0 }, t% p/ E
  11. npm ERR! network This is most likely not a problem with npm itself! p7 I4 O1 ]& d0 b0 J: h. w
  12. npm ERR! network and is related to network connectivity.
    , m3 e! ^( s$ _
  13. npm ERR! network In most cases you are behind a proxy or have bad network settings.
    + n, P& H/ y; o+ W6 H& t2 s
  14. npm ERR! network4 |& _- t* W% K5 @. ^, b
  15. npm ERR! network If you are behind a proxy, please make sure that the3 c& B( C6 T  p. E
  16. npm ERR! network 'proxy' config is set properly.  See: 'npm help config'  R, _! f0 F0 M

  17. , x/ b/ C1 h* z  O  m% B/ C1 S4 f4 Q
  18. npm ERR! Please include the following file with any support request:
    + t' n( M/ A6 O0 C8 D& s' [- d
  19. npm ERR!     C:\Users\Administrator\npm-debug.log
复制代码

" g, _2 v# D) F/ f+ N8 Z% ^, F4 ?
然后查npm的配置,也是一脸懵逼
) K/ p* L; t) x/ _4 ?- g# {& u# I; d# |  x
  1. 4 f& S/ U+ n* ]6 r% F; g
  2. C:\Users\Administrator>npm config ls) l' w' V) p8 q0 o& Z
  3. ; cli configs  S" e# [2 d* S! H, O* X0 X! |
  4. user-agent = "npm/2.15.1 node/v4.4.4 win32 x64"0 o% l) U# g* l4 \) z- L& O

  5. / H/ O( g: E1 f; B
  6. ; userconfig C:\Users\Administrator\.npmrc
    1 L* P! R, h, f. f5 E* w
  7. disturl = "https://npm.taobao.org/dist"$ R$ T- j+ x( C0 ?
  8. proxy = "http://xn--rvg/"
    % T* s8 S  k0 \7 }
  9. registry = "http://registry.npmjs.org/"
    # X8 U+ D  @# f- @* p0 x
  10. strict-ssl = false
    # x$ N- {& R8 c, j
  11. unsafe-perm = true- _+ e  z& H8 U- v4 f2 K( `) M$ J

  12. / y# x; r/ }/ ~: P6 Z- b+ _4 g
  13. ; builtin config undefined" d; y3 Q) b$ M
  14. cache = "C:\\Program Files\\nodejs\\node_global"
    # u3 U3 [/ Q; Z8 |& R
  15. prefix = "C:\\Program Files\\nodejs\\node_global"
    # w1 b7 B% e+ O) I5 ~- I8 {
  16. ' _! v$ i. I5 n6 i) E
  17. ; node bin location = C:\Program Files\nodejs\node.exe
    . K- ~# |' c* V7 t
  18. ; cwd = C:\Users\Administrator6 Q0 ?% w: A& K, a" @/ X
  19. ; HOME = C:\Users\Administrator) P& Q7 O' k1 h, b" M
  20. ; 'npm config ls -l' to show all defaults.
复制代码
3 v4 F$ n' c5 K/ p) p8 a8 X
) Q. F: v. K  b
根据网上的教程,换了N种镜像,问题依旧存在% ?# q  s# b& v. ~) x1 z

0 ^/ p/ [, ^) P( U' b然后终于在网上找到个解决办法:' J' g3 {6 q. b1 G$ k7 n! J8 i( Z
0 O! A9 S. ]1 G9 Z' `, \
  1. 解决办法:
    % C( M; G2 r/ |. z

  2. . k$ U$ ~0 `1 u9 J% j
  3. 1、执行:
    ; J/ H" M: s$ r+ g( n4 w
  4. % L) z* x6 E6 M) K( Z- M! B
  5. npm config get proxy
    ( W5 O0 ~% B$ g3 L( K
  6. npm config get https-proxy. \6 ?& M  I' }; A2 v
  7. 如果返回值不为null,继续执行:
    8 r+ g; Y; N1 a1 i, e& W2 Z
  8. (这一步很重要,一定要保证两个命令的返回值都为null,话说回来,应该出现这个错误这两个返回值有不为null的)
    " }3 Q, S7 V. }/ s( {9 x
  9. npm config set proxy null" Q) W$ ?" O! p$ O+ o8 _
  10. npm config set https-proxy null
    3 t# W# z8 C& [% r/ |+ f4 R
  11. 2、执行:% f, J! k# E; s1 y2 W) K
  12. npm config set registry http://registry.cnpmjs.org/
复制代码
  N1 h% l# y. W1 s( Q" U. {  d/ k7 g
1 \4 C# M& _: ~3 r) l/ e- K
然后你就可以愉快的安装cnpm了
8 Z' m0 o7 m! E- p' {) n; l
) a  r9 ^6 Q& y& m
  1. npm install -g cnpm --registry=https://registry.npm.taobao.org
复制代码
. ^/ P  S, P/ J
然后你就可以更加愉快的用cnpm安任何东西了
回复

使用道具 举报

314

主题

478

回帖

2960

积分

管理员

积分
2960
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"”的问题. Y4 K7 K" a4 R: K! ^# n
$ w) Y: f" [: ?8 E
1、问题描述; \  }* u% \9 ]! O, F- s% u* h& x
5 U+ P7 J6 B2 y6 x( X1 J
某天在使用yarn安装依赖的时候,突然出现如下错误导致安装依赖终止:. o: V- K& A& Q& s, }, S/ N

( V1 f4 e/ ^( |  N$ V
  1. The engine "node" is incompatible with this module. Expected version "^14.18.0 || ^16.14.0 || >=18.0.0". Got "17.9.0"
复制代码

: G( d" t% ^  J- D' [; G5 b( P$ i8 z+ j; V& x) G. Q2 L
2、解决办法, @5 h2 |, B* u' ^: H$ |1 g
使用如下命令忽略错误:9 S1 @8 X. B. F- |
9 Q( O  h- [& e0 y; ]! T
yarn config set ignore-engines true
# \% `9 z$ {1 L; g! O) M! j# ?- x/ i5 ~, m* Z; e# d2 _
然后再使用yarn进行安装即可
回复

使用道具 举报

314

主题

478

回帖

2960

积分

管理员

积分
2960
QQ
 楼主| 发表于 2023-6-9 03:02:21 | 显示全部楼层
  1. tyarn0 `7 m: d* m+ t
  2. yarn install v1.22.19
    ' t" m0 Q: c( K- I; b* H
  3. [1/4] Resolving packages...# d, M5 L' q- B& [* }
  4. [2/4] Fetching packages...( ?1 x0 F; l, T, z3 @
  5. [3/4] Linking dependencies...9 k/ v! |" a/ k7 J  H3 {
  6. warning " > sass-loader@8.0.2" has unmet peer dependency "webpack@^4.36.0 || ^5.0.0".
    & U! P  i( L- R$ f. V1 O' q- v) q
  7. [4/4] Building fresh packages...& ?: I5 n- O2 ~/ K
  8. Done in 19.63s.
    9 \$ y5 g% U$ G1 A4 j* i- ~
  9. PS D:\jsq\formG\form-generator-dev\form-generator-dev> npm run dev. k6 Z4 C' c) h/ K' o

  10. + `$ V: Y& A* x* u. U
  11. > form-generator@0.2.0 dev+ U- H; M' G+ Q8 x
  12. > vue-cli-service serve
    8 R/ i, D; e, }' y& }2 H; d4 I# s1 c
  13. 0 n! v2 t' c( y5 K' \& Z
  14. INFO  Starting development server...5 T: T8 u- v4 R# G/ `- {
  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/ ~4 _4 `  ]" A6 V+ l) f
  16.     at new Hash (node:internal/crypto/hash:71:19)
    6 z& P( a' G* i/ m7 c: K; ^, K
  17.     at Object.createHash (node:crypto:133:10)# b5 Q% N& _, d; f5 @! J. u7 j/ V1 [5 N
  18.     at module.exports (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\util\createHash.js:135:53)9 t1 Z1 {' n% [2 A3 W4 }- R) X
  19.     at NormalModule._initBuildHash (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:417:16)
    & n4 W- v' d! Q9 [
  20.     at handleParseError (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:471:10)
    . M9 |4 \& w4 M  ?9 E7 m2 b
  21.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:503:5
    ) s1 ~: J( ]' ~, ~/ L
  22.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:358:12- z4 _* s) V$ x
  23.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    , l: ~- |* Y* X; j' ]
  24.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:214:10)0 l4 Z- t% p% G) W. A% X
  25.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:221:10)
    6 g3 N5 Z* Y: q' N; s" e- g' @
  26.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:236:36 D, }* ?, H7 r/ g
  27.     at runSyncOrAsync (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:130:11)( g. m0 E% U6 t2 A3 S; ]
  28.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:232:2)0 v$ J* }$ h3 u% l4 s6 u: H6 v; N5 J
  29.     at Array.<anonymous> (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:205:4)7 |1 N- w$ ?* {! |
  30.     at Storage.finished (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    / V3 @1 [4 m7 h5 Z
  31.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9. H% L0 ]/ j) A5 r( j
  32. Error: error:0308010C:digital envelope routines::unsupported5 m! ^5 G# r8 T5 E' m0 @2 q3 p
  33.     at new Hash (node:internal/crypto/hash:71:19)' d# n+ E; _* z& M% E
  34.     at Object.createHash (node:crypto:133:10)/ ^2 H( h; `$ l- Z+ a
  35.     at module.exports (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\util\createHash.js:135:53)
    % }. t9 S3 X; K- |5 \) f
  36.     at NormalModule._initBuildHash (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:417:16)
    7 h1 `5 z* g6 n) B% W7 t
  37.     at handleParseError (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:471:10)
    6 [6 A! t0 [5 w+ w
  38.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:503:5
    6 o0 y6 c1 @5 s- O$ B9 J, ?
  39.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:358:12/ A- u" Q9 X' a
  40.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    : l; Y1 u5 R% Z
  41.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    ) O7 r' q7 U9 b
  42.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:221:10)$ c  L2 W- X; R$ C3 [8 q6 q& x! ~2 [
  43.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:236:3! W" J) s: J: r5 S: ]" x
  44.     at runSyncOrAsync (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:130:11)
    1 Y8 f- v% h+ z7 H9 i( @, r
  45.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:232:2)
    8 ^/ D# [: {; T6 |! n$ b0 q/ g
  46.     at Array.<anonymous> (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:205:4)! u! W2 h  w9 B' }1 X8 I; M' P
  47.     at Storage.finished (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16): k3 P0 g6 E" c2 k" s: D0 R
  48.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:94 L& K7 x. ?- z4 X- p
  49. node:internal/crypto/hash:71* J/ ~" `5 p0 n# I7 R
  50.   this[kHandle] = new _Hash(algorithm, xofLen);2 M3 R0 b3 ~* B3 d, \2 n( m
  51.                   ^5 c; Q: n- B, w* j- H

  52. 3 }+ v3 d$ m: q& x6 W* ]: S
  53. Error: error:0308010C:digital envelope routines::unsupported
    % w- c" f" }2 _) z7 \( o1 K0 u
  54.     at new Hash (node:internal/crypto/hash:71:19)3 H* x: Y& S. b, X) o! N; d
  55.     at Object.createHash (node:crypto:133:10)
    : n$ {/ F7 U" {% d' d' j
  56.     at module.exports (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\util\createHash.js:135:53)
    * B0 ~8 \' o0 V  |
  57.     at NormalModule._initBuildHash (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:417:16)
    6 v5 B- _0 `. v
  58.     at handleParseError (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:471:10)
    ) l* |  G( S7 J0 Q! I4 o% v  x) n+ c
  59.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:503:5
    1 p/ b/ r+ l- X6 \( U' l
  60.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\webpack\lib\NormalModule.js:358:12! x1 `& `1 f# n3 i
  61.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:373:3
    3 r2 I9 c+ P- q5 ^$ L3 I' \8 \& N
  62.     at iterateNormalLoaders (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:214:10)
    ) w+ p$ B8 @# [
  63.     at Array.<anonymous> (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\loader-runner\lib\LoaderRunner.js:205:4)- D- m1 W0 I8 ^4 `: \8 s. B- I
  64.     at Storage.finished (D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:55:16)
    7 _3 n$ h" B; d% j" Z
  65.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\enhanced-resolve\lib\CachedInputFileSystem.js:91:9. w/ V" q0 \+ A; F: r
  66.     at D:\jsq\formG\form-generator-dev\form-generator-dev\node_modules\graceful-fs\graceful-fs.js:123:16& z# \, w/ C1 L; M, d' p
  67.     at FSReqCallback.readFileAfterClose [as oncomplete] (node:internal/fs/read_file_context:68:3) {
      |7 V6 M3 W4 I+ c5 C. R1 m
  68.   opensslErrorStack: [ 'error:03000086:digital envelope routines::initialization error' ],
    3 A9 A  L# B4 K) N) i5 @
  69.   library: 'digital envelope routines',
    % A$ Y. I4 |& g$ Q
  70.   reason: 'unsupported',
    8 u! {0 J+ g  R+ ^; P
  71.   code: 'ERR_OSSL_EVP_UNSUPPORTED'
    2 U2 ]: `; F0 A- ?8 e
  72. }
    & t9 T. ]* C8 B% O( W. C
  73. $ r% k/ I1 T% x" b8 L
  74. Node.js v18.16.0
    4 g9 a! o5 S% H& Z
  75. NativeCommandExitException: Program "npm.cmd" ended with non-zero exit code: 1.
复制代码

; K' T( }) X5 C1 _, v- s7 y! J: L* K
回复

使用道具 举报

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

本版积分规则

QQ|Archiver|手机版|小黑屋|通达产控投资 ( 粤ICP备2023021749号-1|粤公网安备 44030402006137号 )

GMT+8, 2025-4-5 02:06 , Processed in 0.076158 second(s), 21 queries .

Powered by Discuz! X3.5

© 2001-2025 Discuz! Team.

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