gpt4 book ai didi

node.js - 安装 Angular CLI 时出现错误 400 Bad Request

转载 作者:太空宇宙 更新时间:2023-11-04 03:21:19 26 4
gpt4 key购买 nike

我正在使用 npm 安装 Angular CLI,这样我就可以在某些项目中使用 Angular 4。但是,我收到 400 Bad Request 错误。有人也遇到过这个问题并得到了解决方案吗?我已经尝试搜索一些与我的问题相关的内容,但不幸看到一个。

命令:

npm config set proxy="myproxy.com:1234"
npm config set proxy-http="http://registry.npmjs.org/"
npm install -g @angular/cli

编辑:

这是调试日志:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'install',
1 verbose cli '-g',
1 verbose cli '@angular/cli' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose npm-session a495756054a32527
5 silly install loadCurrentTree
6 silly install readGlobalPackageData
7 http fetch GET 400 https://registry.npmjs.org/@angular%2fcli 90ms
8 silly fetchPackageMetaData error for @angular/cli@latest 400 Bad Request: @angular/cli@latest
9 verbose stack Error: 400 Bad Request: @angular/cli@latest
9 verbose stack at fetch.then.res (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\lib\fetchers\registry\fetch.js:42:19)
9 verbose stack at tryCatcher (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\util.js:16:23)
9 verbose stack at Promise._settlePromiseFromHandler (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:512:31)
9 verbose stack at Promise._settlePromise (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:569:18)
9 verbose stack at Promise._settlePromise0 (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:614:10)
9 verbose stack at Promise._settlePromises (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\promise.js:693:18)
9 verbose stack at Async._drainQueue (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:133:16)
9 verbose stack at Async._drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:143:10)
9 verbose stack at Immediate.Async.drainQueues (C:\Program Files\nodejs\node_modules\npm\node_modules\bluebird\js\release\async.js:17:14)
9 verbose stack at runCallback (timers.js:794:20)
9 verbose stack at tryOnImmediate (timers.js:752:5)
9 verbose stack at processImmediate [as _immediateCallback] (timers.js:729:5)
10 verbose cwd C:\
11 verbose Windows_NT 6.1.7601
12 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "@angular/cli"
13 verbose node v8.11.1
14 verbose npm v5.6.0
15 error code E400
16 error 400 Bad Request: @angular/cli@latest
17 verbose exit [ 1, true ]

编辑2:

好的,伙计们,我刚刚通过此设置删除了 400 错误:

npm config set proxy="http://username:password@proxyserverpac:proxyport/"
npm config set https-proxy="http://username:password@proxyserverpac:proxyport/"
npm config set http-proxy="http://username:password@proxyserverpac:proxyport/"
npm config set registry="http://registry.npmjs.org/"

但现在我遇到了这个错误:

0 info it worked if it ends with ok
1 verbose cli [ 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli 'info',
1 verbose cli '@angular/cli' ]
2 info using npm@5.6.0
3 info using node@v8.11.1
4 verbose config Skipping project config: C:\Users\apamintuan/.npmrc. (matches userconfig)
5 silly mapToRegistry name @angular/cli
6 silly mapToRegistry scope (from package name) @angular
7 verbose mapToRegistry no registry URL found in name for scope @angular
8 silly mapToRegistry using default registry
9 silly mapToRegistry registry http://registry.npmjs.org/
10 silly mapToRegistry data { type: 'tag',
10 silly mapToRegistry registry: true,
10 silly mapToRegistry where: undefined,
10 silly mapToRegistry raw: '@angular/cli',
10 silly mapToRegistry name: '@angular/cli',
10 silly mapToRegistry escapedName: '@angular%2fcli',
10 silly mapToRegistry scope: '@angular',
10 silly mapToRegistry rawSpec: '',
10 silly mapToRegistry saveSpec: null,
10 silly mapToRegistry fetchSpec: 'latest',
10 silly mapToRegistry gitRange: undefined,
10 silly mapToRegistry gitCommittish: undefined,
10 silly mapToRegistry hosted: undefined }
11 silly mapToRegistry uri http://registry.npmjs.org/@angular%2fcli
12 verbose request uri http://registry.npmjs.org/@angular%2fcli
13 verbose request no auth needed
14 info attempt registry request try #1 at 12:46:50
15 verbose request id f486fd0b1ab9f374
16 http request GET http://registry.npmjs.org/@angular%2fcli
17 http 404 http://registry.npmjs.org/@angular%2fcli
18 verbose bad json <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
18 verbose bad json <html xmlns="http://www.w3.org/1999/xhtml">
18 verbose bad json <head>
18 verbose bad json <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
18 verbose bad json <title>404 - File or directory not found.</title>
18 verbose bad json <style type="text/css">
18 verbose bad json <!--
18 verbose bad json body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
18 verbose bad json fieldset{padding:0 15px 10px 15px;}
18 verbose bad json h1{font-size:2.4em;margin:0;color:#FFF;}
18 verbose bad json h2{font-size:1.7em;margin:0;color:#CC0000;}
18 verbose bad json h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
18 verbose bad json #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
18 verbose bad json background-color:#555555;}
18 verbose bad json #content{margin:0 0 0 2%;position:relative;}
18 verbose bad json .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
18 verbose bad json -->
18 verbose bad json </style>
18 verbose bad json </head>
18 verbose bad json <body>
18 verbose bad json <div id="header"><h1>Server Error</h1></div>
18 verbose bad json <div id="content">
18 verbose bad json <div class="content-container"><fieldset>
18 verbose bad json <h2>404 - File or directory not found.</h2>
18 verbose bad json <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
18 verbose bad json </fieldset></div>
18 verbose bad json </div>
18 verbose bad json </body>
18 verbose bad json </html>
19 error registry error parsing json
20 verbose headers { 'content-type': 'text/html',
20 verbose headers server: 'Microsoft-IIS/7.5',
20 verbose headers date: 'Tue, 17 Apr 2018 19:46:50 GMT',
20 verbose headers 'content-length': '1245' }
21 verbose stack SyntaxError: Unexpected token < in JSON at position 0
21 verbose stack <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
21 verbose stack <html xmlns="http://www.w3.org/1999/xhtml">
21 verbose stack <head>
21 verbose stack <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
21 verbose stack <title>404 - File or directory not found.</title>
21 verbose stack <style type="text/css">
21 verbose stack <!--
21 verbose stack body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
21 verbose stack fieldset{padding:0 15px 10px 15px;}
21 verbose stack h1{font-size:2.4em;margin:0;color:#FFF;}
21 verbose stack h2{font-size:1.7em;margin:0;color:#CC0000;}
21 verbose stack h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
21 verbose stack #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
21 verbose stack background-color:#555555;}
21 verbose stack #content{margin:0 0 0 2%;position:relative;}
21 verbose stack .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
21 verbose stack -->
21 verbose stack </style>
21 verbose stack </head>
21 verbose stack <body>
21 verbose stack <div id="header"><h1>Server Error</h1></div>
21 verbose stack <div id="content">
21 verbose stack <div class="content-container"><fieldset>
21 verbose stack <h2>404 - File or directory not found.</h2>
21 verbose stack <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
21 verbose stack </fieldset></div>
21 verbose stack </div>
21 verbose stack </body>
21 verbose stack </html>
21 verbose stack
21 verbose stack at JSON.parse (<anonymous>)
21 verbose stack at RegClient.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:243:23)
21 verbose stack at Request._callback (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-registry-client\lib\request.js:216:14)
21 verbose stack at Request.self.callback (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:186:22)
21 verbose stack at emitTwo (events.js:126:13)
21 verbose stack at Request.emit (events.js:214:7)
21 verbose stack at Request.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:1163:10)
21 verbose stack at emitOne (events.js:116:13)
21 verbose stack at Request.emit (events.js:211:7)
21 verbose stack at IncomingMessage.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\request\request.js:1085:12)
21 verbose stack at Object.onceWrapper (events.js:313:30)
21 verbose stack at emitNone (events.js:111:20)
21 verbose stack at IncomingMessage.emit (events.js:208:7)
21 verbose stack at endReadableNT (_stream_readable.js:1064:12)
21 verbose stack at _combinedTickCallback (internal/process/next_tick.js:138:11)
21 verbose stack at process._tickCallback (internal/process/next_tick.js:180:9)
22 verbose cwd C:\Users\apamintuan
23 verbose Windows_NT 6.1.7601
24 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "info" "@angular/cli"
25 verbose node v8.11.1
26 verbose npm v5.6.0
27 error Unexpected token < in JSON at position 0
27 error <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
27 error <html xmlns="http://www.w3.org/1999/xhtml">
27 error <head>
27 error <meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1"/>
27 error <title>404 - File or directory not found.</title>
27 error <style type="text/css">
27 error <!--
27 error body{margin:0;font-size:.7em;font-family:Verdana, Arial, Helvetica, sans-serif;background:#EEEEEE;}
27 error fieldset{padding:0 15px 10px 15px;}
27 error h1{font-size:2.4em;margin:0;color:#FFF;}
27 error h2{font-size:1.7em;margin:0;color:#CC0000;}
27 error h3{font-size:1.2em;margin:10px 0 0 0;color:#000000;}
27 error #header{width:96%;margin:0 0 0 0;padding:6px 2% 6px 2%;font-family:"trebuchet MS", Verdana, sans-serif;color:#FFF;
27 error background-color:#555555;}
27 error #content{margin:0 0 0 2%;position:relative;}
27 error .content-container{background:#FFF;width:96%;margin-top:8px;padding:10px;position:relative;}
27 error -->
27 error </style>
27 error </head>
27 error <body>
27 error <div id="header"><h1>Server Error</h1></div>
27 error <div id="content">
27 error <div class="content-container"><fieldset>
27 error <h2>404 - File or directory not found.</h2>
27 error <h3>The resource you are looking for might have been removed, had its name changed, or is temporarily unavailable.</h3>
27 error </fieldset></div>
27 error </div>
27 error </body>
27 error </html>
28 verbose exit [ 1, true ]

有人可以指导我如何克服这个问题吗?

编辑3:

此问题现已解决。

下面的答案/评论都没有解决我的问题。

但是,感谢您在此提供的所有意见。我很感激。

解决方案:我认为使用公司的代理服务器可以解决问题,但我不知道 fiddler 是唯一的答案。我使用它并将 npm 中的代理设置为 ' http://localhost:8888/ ' 然后安装就完成了。

最佳答案

1.open 命令提示

2.运行命令“npm config edit”(打开一个文件)

3.删除了身份验证部分“strict-ssl=true 和 3-4 行”并保存文件

然后再次安装 Angular cli

关于node.js - 安装 Angular CLI 时出现错误 400 Bad Request,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/49782733/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com