当前位置: 首页 > 知识库问答 >
问题:

npm安装期间JSON中出现意外令牌

郎增
2023-03-14

最近我的电脑无法运行npm安装。

我知道这个问题已经被问过了,无论如何,我已经检查了许多类似的问题,但仍然没有帮助。所以我在下面的代码下尝试添加更多信息。

问题第一。

$ npm install -dd
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
npm verb cli   'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli   'install',
npm verb cli   '-dd' ]
npm info using npm@5.6.0
npm info using node@v8.11.3
npm verb npm-session 6b461ab74bbc6682
npm info lifecycle rcm-client@1.0.0~preinstall: rcm-client@1.0.0
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-copy 358ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-uglify 360ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-cli 364ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-concat 363ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/archiver 369ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-clean 364ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-contrib-jshint 363ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/jshint 268ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-war 272ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-replace 275ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-stryker 274ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/jasmine-core 273ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-karma 284ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-sonar-runner 278ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-ie-launcher 278ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-junit-reporter 282ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma 287ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-coverage 284ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-jasmine 284ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-ng-html2js-preprocessor 287ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-phantomjs-launcher 287ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/phantomjs-prebuilt 271ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-script-launcher 321ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker 313ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-api 317ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-html-reporter 312ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/karma-spec-reporter 322ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-jasmine 313ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt-angular-templates 1303ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/grunt 1308ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-mocks 1324ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/stryker-karma-runner 274ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular 249ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-ui-bootstrap 250ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-route 253ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-utils-pagination 251ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-utils-pagination 253ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-ui-bootstrap 267ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular 271ms (from cache)
npm http fetch GET 200 https://registry.npmjs.org/angular-route 273ms (from cache)
npm verb stack SyntaxError: Unexpected token < in JSON at position 0 while parsing near '<html><head><meta co...'
npm verb stack     at JSON.parse (<anonymous>)
npm verb stack     at parseJson (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\node_modules\node-fetch-npm\node_modules\json-parse-better-errors\index.js:7:17)
npm verb stack     at consumeBody.call.then.buffer (C:\Program Files\nodejs\node_modules\npm\node_modules\pacote\node_modules\make-fetch-happen\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:188:7)
npm verb cwd C:\git_workspace\rcm-client
npm verb Windows_NT 6.1.7601
npm verb argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-dd"
npm verb node v8.11.3
npm verb npm  v5.6.0
npm ERR! Unexpected token < in JSON at position 0 while parsing near '<html><head><meta co...'
npm verb exit [ 1, true ]

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxxxxx\AppData\Roaming\npm-cache\_logs\2018-07-13T07_59_49_943Z-debug.log

我周围的所有人(在同一个办公室、网络、代理等)都没有这个问题,我的电脑以前能够运行这个命令。这似乎不是连接问题,因为我在这里找到了(在NodeJs中检查互联网连接)以下函数来检查URL是否可以解析,它得到的答案是“连接”

require('dns').resolve('www.wikipedia.com', function(err) {
  if (err) {
     console.log("No connection");
  } else {
     console.log("Connected");
  }
});
> Connected

即使我清理了缓存,你也可以看到每个url都是从缓存中获取的:

  • 我手动删除了C:\Program Files\NodeJ中的缓存,并从命令行运行npm cache clean-force。这个缓存还能在哪里

有什么暗示吗?

共有1个答案

尹正奇
2023-03-14

最后,我从我用户的文件夹和缓存中删除了很多文件夹。卸载并重新安装了几乎所有的东西,但都没有成功,运行了许多从互联网复制粘贴的命令,手动删除了环境变量HTTP[s]\u代理,但……总是出现同样的错误。

最后,解决方案是:

npm config rm proxy
npm config rm https-proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy

我不知道我在C:\users\xxxx \[删除了node、nmp等名称中的所有内容]中删除的所有内容是否都包括结果。

这个答案已经在stackoverflow中了,但不是主答案,所以我没有注意到在这么多相似的答案之间,直到我拼命开始复制粘贴任何东西,

用户是私有的,来源是:如何清除NPM的https代理设置?

更新:只有重新运行命令,我才能构建。至少在重新启动控制台后,我无法工作,直到再次运行以下命令:

npm config rm proxy
npm config rm https-proxy
unset HTTP_PROXY
unset HTTPS_PROXY
unset http_proxy
unset https_proxy

要让它再次工作。。。

 类似资料:
  • 问题内容: 我在解析简单的JSON字符串时遇到问题。我已经在JSONLint上检查了它们,它表明它们是有效的。但是当我尝试使用jQuery替代方法解析它们时,出现了以下错误: 注意:我正在使用PHP 对字符串进行编码。 问题答案: 您的数据已经是一个对象。无需解析。javascript解释器已经为您解析了它。

  • 我在安装NPM时遇到以下错误: npm WARN Worker-Loader@0.8.1需要WebPack@>=0.9<2^2.1.0-Beta^2.2.0的对等项,但未安装任何对等项。 npm警告可选跳过可选依赖项:fsevents@1.1.2(node_modules\fsevents): npm WARN notsup跳过可选依赖项:fsevents@1.1.2:wanted平台不受支持{“

  • 我创建了一个自定义验证规则来检查数据库中是否存在用户名。 My User类有一个用户名,该用户名具有自定义验证规则,当创建对象时,它会在数据库中检查是否存在相同的用户名。 我使用<code>界面UserRepository扩展JpaRepositor 我可以分别验证用户并将他们保存到数据库中,但是在一起使用时,比如调用< code > user repository . save(user); <

  • 问题内容: 我在 nodejs 上创建了一个简约的API,该API 以JSON格式返回数据。 但是每次我尝试进行ajax#get调用并将API作为URL传递时,我都会收到错误消息,从Chrome判断,我得到了错误消息。 这是 nodejs + express中 的服务器代码: 从返回的JSON 是:。 这是我从客户端js拨打的电话: 当绘制错误时,我得到: 有人能帮我吗? 我知道已经问过这个问题,

  • 问题内容: // if the box is outside the window, move it to the end function checkEdge() { var windowsLeftEdge = $(‘#window’).position().left; 我在上面提到的行上收到了UncaughtSyntaxError:意外的令牌ILLEGAL。它仅在GoogleChrome和Sa

  • 问题内容: 我刚刚在大学课程中开始使用node.js和json对象。本周我们的任务之一是创建一些json对象,并将对象的一部分提取到html页面中。我以为自己对此有很好的掌握,但是尝试启动节点时遇到了错误。如果我删除了colleges对象和parse语句,则节点运行正常。 这是我运行“ node index.js”时遇到的错误: 这是我正在使用的代码。 任何有关我做错事情的提示将不胜感激。我的教练