代码之家  ›  专栏  ›  技术社区  ›  Wolf359

Angular CLI安装速度非常慢,完成时出错

  •  -1
  • Wolf359  · 技术社区  · 6 年前

    我是这样做的:

    ~$ node --version
    v8.12.0
    ~$ npm -version
    6.4.1
    

    ~$ npm cache clean --force
    npm WARN using --force I sure hope you know what you are doing.
    
    ~$ npm install -g @angular/cli@latest
    

    这需要很长时间。它挂在:

    fetchMetadata: sill resolveWithNewModule @angular/cli@6.2.5 checking installable status
    

    sudo iftop -i wlp3s0
    

    过滤“npmjs”(用于 https://registry.npmjs.org/

    我也尝试过https->http命令:

    npm config set registry http://registry.npmjs.org/
    

    但结果还是一样。只是挂在不同的阶段。

    最后是:

    ~$ npm install -g @angular/cli
    npm ERR! Unexpected end of JSON input while parsing near '...marked":"^1.0.0","bra'
    
    npm ERR! A complete log of this run can be found in:
    npm ERR!     /home/<owner>/.npm/_logs/2018-10-14T21_00_48_107Z-debug.log
    

    0 info it worked if it ends with ok
    1 verbose cli [ '/opt/node/bin/node',
    1 verbose cli   '/opt/node/bin/npm',
    1 verbose cli   'install',
    1 verbose cli   '-g',
    1 verbose cli   '@angular/cli' ]
    2 info using npm@6.4.1
    3 info using node@v8.12.0
    4 verbose npm-session c5776088b57d247a
    5 silly install loadCurrentTree
    6 silly install readGlobalPackageData
    7 http fetch GET 200 http://registry.npmjs.org/@angular%2fcli 22ms (from cache)
    8 silly pacote tag manifest for @angular/cli@latest fetched in 44ms
    9 timing stage:loadCurrentTree Completed in 209ms
    10 silly install loadIdealTree
    11 silly install cloneCurrentTreeToIdealTree
    12 timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
    13 silly install loadShrinkwrap
    14 timing stage:loadIdealTree:loadShrinkwrap Completed in 4ms
    15 silly install loadAllDepsIntoIdealTree
    16 silly resolveWithNewModule @angular/cli@6.2.5 checking installable status
    17 http fetch GET 200 http://registry.npmjs.org/@angular-devkit%2fcore 39ms (from cache)
    18 http fetch GET 200 http://registry.npmjs.org/@angular-devkit%2farchitect 41ms (from cache)
    19 http fetch GET 200 http://registry.npmjs.org/@angular-devkit%2fschematics 41ms (from cache)
    20 http fetch GET 200 http://registry.npmjs.org/@schematics%2fangular 43ms (from cache)
    21 http fetch GET 200 http://registry.npmjs.org/json-schema-traverse 44ms (from cache)
    22 http fetch GET 200 http://registry.npmjs.org/@schematics%2fupdate 45ms (from cache)
    23 http fetch GET 200 http://registry.npmjs.org/opn 43ms (from cache)
    24 http fetch GET 200 http://registry.npmjs.org/semver 47ms (from cache)
    25 http fetch GET 200 http://registry.npmjs.org/rxjs 49ms (from cache)
    26 http fetch GET 200 http://registry.npmjs.org/symbol-observable 51ms (from cache)
    27 silly pacote version manifest for @angular-devkit/core@0.8.5 fetched in 65ms
    28 silly resolveWithNewModule @angular-devkit/core@0.8.5 checking installable status
    29 silly pacote version manifest for @angular-devkit/architect@0.8.5 fetched in 68ms
    30 silly resolveWithNewModule @angular-devkit/architect@0.8.5 checking installable status
    31 silly pacote version manifest for @angular-devkit/schematics@0.8.5 fetched in 67ms
    32 silly resolveWithNewModule @angular-devkit/schematics@0.8.5 checking installable status
    33 silly pacote version manifest for @schematics/angular@0.8.5 fetched in 67ms
    34 silly resolveWithNewModule @schematics/angular@0.8.5 checking installable status
    35 silly pacote range manifest for json-schema-traverse@^0.4.1 fetched in 67ms
    36 silly resolveWithNewModule json-schema-traverse@0.4.1 checking installable status
    37 silly pacote version manifest for @schematics/update@0.8.5 fetched in 67ms
    38 silly resolveWithNewModule @schematics/update@0.8.5 checking installable status
    39 silly pacote range manifest for opn@^5.3.0 fetched in 65ms
    40 silly resolveWithNewModule opn@5.4.0 checking installable status
    41 silly pacote range manifest for rxjs@~6.2.0 fetched in 68ms
    42 silly resolveWithNewModule rxjs@6.2.2 checking installable status
    43 silly pacote range manifest for semver@^5.1.0 fetched in 69ms
    44 silly resolveWithNewModule semver@5.6.0 checking installable status
    45 silly pacote range manifest for symbol-observable@^1.2.0 fetched in 69ms
    46 silly resolveWithNewModule symbol-observable@1.2.0 checking installable status
    47 http fetch GET 200 http://registry.npmjs.org/yargs-parser 9ms (from cache)
    48 silly pacote range manifest for yargs-parser@^10.0.0 fetched in 11ms
    49 silly resolveWithNewModule yargs-parser@10.1.0 checking installable status
    50 http fetch GET 200 http://registry.npmjs.org/chokidar 6ms (from cache)
    51 http fetch GET 200 http://registry.npmjs.org/ajv 7ms (from cache)
    52 http fetch GET 200 http://registry.npmjs.org/source-map 42ms (from cache)
    53 silly pacote range manifest for chokidar@^2.0.3 fetched in 46ms
    54 silly resolveWithNewModule chokidar@2.0.4 checking installable status
    55 silly pacote range manifest for ajv@~6.4.0 fetched in 47ms
    56 silly resolveWithNewModule ajv@6.4.0 checking installable status
    57 silly pacote range manifest for source-map@^0.5.6 fetched in 47ms
    58 silly resolveWithNewModule source-map@0.5.7 checking installable status
    59 silly pacote range manifest for json-schema-traverse@^0.3.0 fetched in 2ms
    60 silly resolveWithNewModule json-schema-traverse@0.3.1 checking installable status
    61 http fetch GET 200 http://registry.npmjs.org/fast-json-stable-stringify 8ms (from cache)
    62 http fetch GET 200 http://registry.npmjs.org/fast-deep-equal 9ms (from cache)
    63 http fetch GET 200 http://registry.npmjs.org/uri-js 9ms (from cache)
    64 silly pacote range manifest for fast-json-stable-stringify@^2.0.0 fetched in 11ms
    65 silly resolveWithNewModule fast-json-stable-stringify@2.0.0 checking installable status
    66 silly pacote range manifest for fast-deep-equal@^1.0.0 fetched in 12ms
    67 silly resolveWithNewModule fast-deep-equal@1.1.0 checking installable status
    68 silly pacote range manifest for uri-js@^3.0.2 fetched in 12ms
    69 silly resolveWithNewModule uri-js@3.0.2 checking installable status
    70 http fetch GET 200 http://registry.npmjs.org/punycode 2ms (from cache)
    71 silly pacote range manifest for punycode@^2.1.0 fetched in 4ms
    72 silly resolveWithNewModule punycode@2.1.1 checking installable status
    73 http fetch GET 200 http://registry.npmjs.org/anymatch 20ms (from cache)
    74 http fetch GET 200 http://registry.npmjs.org/async-each 18ms (from cache)
    75 http fetch GET 200 http://registry.npmjs.org/braces 18ms (from cache)
    76 http fetch GET 200 http://registry.npmjs.org/glob-parent 17ms (from cache)
    77 http fetch GET 200 http://registry.npmjs.org/inherits 17ms (from cache)
    78 http fetch GET 200 http://registry.npmjs.org/is-binary-path 17ms (from cache)
    79 http fetch GET 200 http://registry.npmjs.org/is-glob 17ms (from cache)
    80 http fetch GET 200 http://registry.npmjs.org/lodash.debounce 16ms (from cache)
    81 http fetch GET 200 http://registry.npmjs.org/normalize-path 17ms (from cache)
    82 silly fetchPackageMetaData error for braces@^2.3.0 Unexpected end of JSON input while parsing near '...marked":"^1.0.0","bra'
    83 http fetch GET 200 http://registry.npmjs.org/path-is-absolute 21ms (from cache)
    84 silly pacote range manifest for anymatch@^2.0.0 fetched in 28ms
    85 silly resolveWithNewModule anymatch@2.0.0 checking installable status
    86 silly pacote range manifest for async-each@^1.0.0 fetched in 27ms
    87 silly resolveWithNewModule async-each@1.0.1 checking installable status
    88 silly pacote range manifest for glob-parent@^3.1.0 fetched in 26ms
    89 silly resolveWithNewModule glob-parent@3.1.0 checking installable status
    90 silly pacote range manifest for inherits@^2.0.1 fetched in 26ms
    91 silly resolveWithNewModule inherits@2.0.3 checking installable status
    92 silly pacote range manifest for is-binary-path@^1.0.0 fetched in 26ms
    93 silly resolveWithNewModule is-binary-path@1.0.1 checking installable status
    94 silly pacote range manifest for is-glob@^4.0.0 fetched in 27ms
    95 silly resolveWithNewModule is-glob@4.0.0 checking installable status
    96 silly pacote range manifest for lodash.debounce@^4.0.8 fetched in 27ms
    97 silly resolveWithNewModule lodash.debounce@4.0.8 checking installable status
    98 silly pacote range manifest for normalize-path@^2.1.1 fetched in 27ms
    99 silly resolveWithNewModule normalize-path@2.1.1 checking installable status
    100 silly pacote range manifest for path-is-absolute@^1.0.0 fetched in 30ms
    101 silly resolveWithNewModule path-is-absolute@1.0.1 checking installable status
    102 http fetch GET 200 http://registry.npmjs.org/readdirp 17ms (from cache)
    103 http fetch GET 200 http://registry.npmjs.org/upath 11ms (from cache)
    104 http fetch GET 200 http://registry.npmjs.org/fsevents 11ms (from cache)
    105 silly pacote range manifest for readdirp@^2.0.0 fetched in 22ms
    106 silly resolveWithNewModule readdirp@2.2.1 checking installable status
    107 silly pacote range manifest for upath@^1.0.5 fetched in 16ms
    108 silly resolveWithNewModule upath@1.1.0 checking installable status
    109 silly pacote range manifest for fsevents@^1.2.2 fetched in 17ms
    110 silly resolveWithNewModule fsevents@1.2.4 checking installable status
    111 silly tarball trying https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz by hash: sha512-z8H8/diyk76B7q5wg+Ud0+CqzcAF3mBBI/bA5ne5zrRUUIvNkJY//D3BqyH571KuAC4Nr7Rw7CjWX4r0y9DvNg==
    112 silly extract https://registry.npmjs.org/fsevents/-/fsevents-1.2.4.tgz extracted to /tmp/npm-8216-7cbe3717/unpack-c30ea2f4 (228ms)
    113 silly addBundled read tarball
    114 silly cleanup remove extracted module
    115 timing stage:rollbackFailedOptional Completed in 1ms
    116 timing stage:runTopLevelLifecycles Completed in 882ms
    117 verbose stack SyntaxError: Unexpected end of JSON input while parsing near '...marked":"^1.0.0","bra'
    117 verbose stack     at JSON.parse (<anonymous>)
    117 verbose stack     at parseJson (/opt/node/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
    117 verbose stack     at consumeBody.call.then.buffer (/opt/node/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
    117 verbose stack     at <anonymous>
    117 verbose stack     at process._tickCallback (internal/process/next_tick.js:189:7)
    118 verbose cwd /home/myuser
    119 verbose Linux 4.15.0-36-generic
    120 verbose argv "/opt/node/bin/node" "/opt/node/bin/npm" "install" "-g" "@angular/cli"
    121 verbose node v8.12.0
    122 verbose npm  v6.4.1
    123 error Unexpected end of JSON input while parsing near '...marked":"^1.0.0","bra'
    124 verbose exit [ 1, true ]
    

    我的网络连接很好,我做了速度测试,浏览网站一般都很好。只是为了确保我也重新启动了路由器/调制解调器。

    我不是在防火墙或代理后面。

    有什么问题吗?

    感谢您的帮助!

    更新:当我跑步时

    npm install -g @angular/cli@latest --verbose
    

    我在输出中得到这些行(以及其他行):

    npm http fetch GET 200 https://registry.npmjs.org/@angular%2fcli 182470ms
    npm timing stage:loadCurrentTree Completed in 182648ms
    

    每人3分钟。 所以不是我而是registry.npmjs.org??

    状态站点显示一切正常: https://status.npmjs.org/ !??

    更新2:

    npm timing stage:runTopLevelLifecycles Completed in 560195ms
    npm verb stack SyntaxError: Unexpected end of JSON input while parsing near '...:"^0.4.2","js-beautif'
    npm verb stack     at JSON.parse (<anonymous>)
    npm verb stack     at parseJson (/opt/node/lib/node_modules/npm/node_modules/json-parse-better-errors/index.js:7:17)
    npm verb stack     at consumeBody.call.then.buffer (/opt/node/lib/node_modules/npm/node_modules/node-fetch-npm/src/body.js:96:50)
    npm verb stack     at <anonymous>
    npm verb stack     at process._tickCallback (internal/process/next_tick.js:189:7)
    
    2 回复  |  直到 6 年前
        1
  •  0
  •   Wolf359    6 年前

    经过几十次的尝试,很多很多个小时后,它终于从自己解决了。

    ~$ npm install -g @angular/cli@latest --verbose
    npm info it worked if it ends with ok
    npm verb cli [ '/opt/node/bin/node',
    npm verb cli   '/opt/node/bin/npm',
    npm verb cli   'install',
    npm verb cli   '-g',
    npm verb cli   '@angular/cli@latest',
    npm verb cli   '--verbose' ]
    npm info using npm@6.4.1
    npm info using node@v10.12.0
    npm verb npm-session b518ace2714f8907
    npm http fetch GET 200 https://registry.npmjs.org/@angular%2fcli 670ms
    npm timing stage:loadCurrentTree Completed in 826ms
    npm timing stage:loadIdealTree:cloneCurrentTree Completed in 0ms
    npm timing stage:loadIdealTree:loadShrinkwrap Completed in 2ms
    npm http fetch GET 200 https://registry.npmjs.org/@angular-devkit%2farchitect 253ms
    npm http fetch GET 200 https://registry.npmjs.org/json-schema-traverse 301ms
    npm http fetch GET 200 https://registry.npmjs.org/symbol-observable 386ms
    
    ... many more lines ....
    
    npm http fetch GET 200 https://registry.npmjs.org/is-wsl 102ms
    npm http fetch GET 200 https://registry.npmjs.org/camelcase 95ms
    npm timing stage:loadIdealTree:loadAllDepsIntoIdealTree Completed in 84528ms
    npm timing stage:loadIdealTree Completed in 84651ms
    npm timing stage:generateActionsToTake Completed in 96ms
    npm verb correctMkdir /home/myuser/.npm/_locks correctMkdir not in flight; initializing
    npm verb makeDirectory /home/myuser/.npm/_locks creation not in flight; initializing
    npm verb lock using /home/myuser/.npm/_locks/staging-839dd594c5d4c44e.lock for /opt/node/lib/node_modules/.staging
    npm http fetch GET 200 https://registry.npmjs.org/combined-stream 86ms (from cache)
    npm http fetch GET 200 https://registry.npmjs.org/json-schema-traverse/-/json-schema-traverse-0.3.1.tgz 111ms
    
    ... many more lines ....
    
    
    npm http fetch GET 200 https://registry.npmjs.org/atob/-/atob-2.1.2.tgz 47036ms
    npm http fetch GET 200 https://registry.npmjs.org/har-schema/-/har-schema-2.0.0.tgz 76429ms
    npm http fetch GET 200 https://registry.npmjs.org/ret/-/ret-0.1.15.tgz 87815ms
    npm timing action:extract Completed in 90290ms
    npm timing action:finalize Completed in 223ms
    npm timing action:refresh-package-json Completed in 536ms
    npm info lifecycle json-schema-traverse@0.3.1~preinstall: json-schema-traverse@0.3.1
    
    ... many more lines ....
    
    npm info lifecycle kind-of@3.2.2~preinstall: kind-of@3.2.2
    npm info lifecycle kind-of@4.0.0~preinstall: kind-of@4.0.0
    npm timing action:preinstall Completed in 48ms
    npm info linkStuff json-schema-traverse@0.3.1
    npm info linkStuff ansi-regex@2.1.1
    npm info linkStuff aproba@1.2.0
    
    ... many more lines ....
    
    
    npm info lifecycle opn@5.4.0~postinstall: opn@5.4.0
    npm info lifecycle symbol-observable@1.2.0~postinstall: symbol-observable@1.2.0
    npm info lifecycle yargs-parser@10.1.0~postinstall: yargs-parser@10.1.0
    npm info lifecycle @angular/cli@6.2.5~postinstall: @angular/cli@6.2.5
    npm timing action:postinstall Completed in 66ms
    npm verb unlock done using /home/myuser/.npm/_locks/staging-839dd594c5d4c44e.lock for /opt/node/lib/node_modules/.staging
    npm timing stage:executeActions Completed in 91462ms
    npm timing stage:rollbackFailedOptional Completed in 104ms
    npm timing stage:runTopLevelLifecycles Completed in 177168ms
    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.2.4 (node_modules/@angular/cli/node_modules/fsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.2.4: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
    npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid OS:    darwin
    npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Valid Arch:  any
    npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual OS:   linux
    npm verb notsup SKIPPING OPTIONAL DEPENDENCY: Actual Arch: x64
    
    + @angular/cli@6.2.5
    added 242 packages from 191 contributors in 177.174s
    npm verb exit [ 0, true ]
    npm timing npm Completed in 177486ms
    npm info ok 
    :~$ ng -version
    
         _                      _                 ____ _     ___
        / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
       / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
      / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
     /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                    |___/
    
    
    Angular CLI: 6.2.5
    Node: 10.12.0
    OS: linux x64
    Angular: 
    ... 
    
    Package                      Version
    ------------------------------------------------------
    @angular-devkit/architect    0.8.5
    @angular-devkit/core         0.8.5
    @angular-devkit/schematics   0.8.5
    @schematics/angular          0.8.5
    @schematics/update           0.8.5
    rxjs                         6.2.2
    typescript                   2.9.2
    

    我把这个留在这儿,希望它能帮助别人。

        2
  •  0
  •   Meligy    6 年前

    首先,您的配置似乎没有工作,因为NPM仍在讨论 https http

    也许用引号再试一次 npm config set registry "http://registry.npmjs.org"

    8.8.8.8 . 试试看。如果您正在使用Wifi,请尝试删除Wifi并重新连接。

    你有代理人吗?这是大多数NPM问题的核心,通常在Windows上,也可能在Linux上。尝试在NPM中设置代理。比如:

    npm config set registry "http://registry.npmjs.org/"
    npm config set http-proxy "http://username:password@ip:port"
    npm config set https-proxy "http://username:password@ip:port"
    npm set strict-ssl false
    

    Source