jjzjj

windows - npm install 在 Windows 上非常脆弱

coder 2024-06-13 原文

我有一个使用 grunt build 的项目。这是我的 packages.json。

...
"devDependencies": {
  "grunt": "^0.4.4",
  "grunt-autoprefixer": "^0.7.3",
  "grunt-coffeelint": "0.0.10",
  "grunt-concurrent": "^0.5.0",
  "grunt-connect-proxy": "^0.1.10",
  "grunt-contrib-clean": "^0.5.0",
  "grunt-contrib-concat": "^0.4.0",
  "grunt-contrib-connect": "^0.7.1",
  "grunt-contrib-copy": "^0.5.0",
  "grunt-contrib-csslint": "^0.2.0",
  "grunt-contrib-cssmin": "^0.9.0",
  "grunt-contrib-jshint": "^0.10.0",
  "grunt-contrib-less": "^0.11.0",
  "grunt-contrib-requirejs": "^0.4.4",
  "grunt-contrib-stylus": "^0.15.1",
  "grunt-contrib-uglify": "^0.4.0",
  "grunt-contrib-watch": "^0.6.1",
  "grunt-modernizr": "^0.5.2",
  "grunt-newer": "^0.7.0",
  "jshint-stylish": "^0.2.0",
  "load-grunt-tasks": "^0.4.0",
  "rjs-build-analysis": "0.0.3",
  "time-grunt": "^0.3.1"
},
...

我正在运行 npm 1.4.13 和 Node v0.10.28

当我运行 clean npm install 时,总是会出现一些随机错误。而且每次都是不同的模块。然后,如果错误来自缓存文件夹,我必须运行 npm cache clean,或者如果错误来自 node_modules 文件夹,则删除 node_modules。然后我必须重试几次才能绕过错误。我尝试了 Windows 8、Windows 7 和 Windows Server 2008。这是错误日志之一。

C:\src>npm install
npm ERR! unpack Could not read data for sigmund@1.0.0
npm ERR! Error: ENOENT, chmod 'C:\src\node_modules\l
oad-grunt-tasks\node_modules\multimatch\node_modules\minimatch\node_modules\lru-
cache\CONTRIBUTORS'
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\no
dejs\\\\node.exe" "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\n
odejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\src
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.13
npm ERR! path C:\src\node_modules\load-grunt-tasks\n
ode_modules\multimatch\node_modules\minimatch\node_modules\lru-cache\CONTRIBUTOR
S
npm ERR! fstream_path C:\src\node_modules\load-grunt
-tasks\node_modules\multimatch\node_modules\minimatch\node_modules\lru-cache\CON
TRIBUTORS
npm ERR! fstream_type File
npm ERR! fstream_class FileWriter
npm ERR! fstream_finish_call chmod
npm ERR! code ENOENT
npm ERR! errno 34
npm ERR! fstream_stack C:\src\packages\Ncapsulate.Node.0.10.28\no
dejs\node_modules\fstream\lib\writer.js:305:19
npm ERR! fstream_stack Object.oncomplete (fs.js:107:15)
npm ERR! Failed to parse json
npm ERR! Unexpected end of input
npm ERR! File: C:\Users\tim\AppData\Roaming\npm-cache\sigmund\1.0.0\package\pack
age.json
npm ERR! Failed to parse package.json data.
npm ERR! package.json must be actual JSON, not just JavaScript.
npm ERR!
npm ERR! This is not a bug in npm.
npm ERR! Tell the package author to fix their package.json file. JSON.parse

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\no
dejs\\\\node.exe" "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\n
odejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\src
npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.13
npm ERR! file C:\Users\tim\AppData\Roaming\npm-cache\sigmund\1.0.0\package\packa
ge.json
npm ERR! code EJSONPARSE
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\src\npm-debug.log
npm ERR! not ok code 0

有时它只是无法从注册表中获取模块。例如:

npm WARN package.json rjs-build-analysis@0.0.3 No repository field.
npm ERR! Error: failed to fetch from registry: lodash
npm ERR!     at RegClient.<anonymous> (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\npm-registry-client\lib\get.js:133:18)
npm ERR!     at cb (C:\src\packages\Ncapsulate.Node.0.10.28\nodej
s\node_modules\npm-registry-client\lib\request.js:32:9)
npm ERR!     at RegClient.<anonymous> (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\npm-registry-client\lib\request.js:107:16)
npm ERR!     at cb (C:\src\packages\Ncapsulate.Node.0.10.28\nodej
s\node_modules\npm-registry-client\lib\request.js:132:9)
npm ERR!     at RegClient.<anonymous> (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\npm-registry-client\lib\request.js:286:12)
npm ERR!     at Request._callback (C:\src\packages\Ncapsulate.Nod
e.0.10.28\nodejs\node_modules\npm-registry-client\lib\request.js:212:65)
npm ERR!     at Request.self.callback (C:\src\packages\Ncapsulate
.Node.0.10.28\nodejs\node_modules\request\request.js:123:22)
npm ERR!     at Request.EventEmitter.emit (events.js:98:17)
npm ERR!     at Request.<anonymous> (C:\src\packages\Ncapsulate.N
ode.0.10.28\nodejs\node_modules\request\request.js:893:14)
npm ERR!     at Request.EventEmitter.emit (events.js:117:20)
npm ERR! If you need help, you may report this *entire* log,
npm ERR! including the npm and node versions, at:
npm ERR!     <http://github.com/npm/npm/issues>

npm ERR! System Windows_NT 6.2.9200
npm ERR! command "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\no
dejs\\\\node.exe" "C:\\src\\packages\\Ncapsulate.Node.0.10.28\\n
odejs\\node_modules\\npm\\bin\\npm-cli.js" "install"
npm ERR! cwd C:\src\npm ERR! node -v v0.10.28
npm ERR! npm -v 1.4.13
npm ERR! registry error parsing json
npm ERR!
npm ERR! Additional logging details can be found in:
npm ERR!     C:\src\npm-debug.log
npm ERR! not ok code 0

我认为远程 npm registry 不稳定,所以我设置了一个本地 npm registry 镜像。但是错误仍然存​​在。我不知道为什么 npm 在 windows 上如此不稳定。

最佳答案

npm ERR! registry error parsing json

相关模块的 package.json 文件丢失或有语法错误

npm ERR! Error: failed to fetch from registry: lodash

有问题的模块不在注册表中

npm ERR! cwd C:\src

问题路径不存在

npm ERR! Error: ENOENT, chmod 'C:\src\node_modules\l

没有修改相关路径的权限

验证安装过程:

  • 您是否以管理员身份安装,然后以普通用户身份运行 npm?
  • 您是否将 nodeJS 安装到 protected 目录中?
  • 您是否正确设置了 PATH?

引用资料

关于windows - npm install 在 Windows 上非常脆弱,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/24817714/

有关windows - npm install 在 Windows 上非常脆弱的更多相关文章

  1. ruby - 在 Ruby 程序执行时阻止 Windows 7 PC 进入休眠状态 - 2

    我需要在客户计算机上运行Ruby应用程序。通常需要几天才能完成(复制大备份文件)。问题是如果启用sleep,它会中断应用程序。否则,计算机将持续运行数周,直到我下次访问为止。有什么方法可以防止执行期间休眠并让Windows在执行后休眠吗?欢迎任何疯狂的想法;-) 最佳答案 Here建议使用SetThreadExecutionStateWinAPI函数,使应用程序能够通知系统它正在使用中,从而防止系统在应用程序运行时进入休眠状态或关闭显示。像这样的东西:require'Win32API'ES_AWAYMODE_REQUIRED=0x0

  2. ruby - 在 Windows 机器上使用 Ruby 进行开发是否会适得其反? - 2

    这似乎非常适得其反,因为太多的gem会在window上破裂。我一直在处理很多mysql和ruby​​-mysqlgem问题(gem本身发生段错误,一个名为UnixSocket的类显然在Windows机器上不能正常工作,等等)。我只是在浪费时间吗?我应该转向不同的脚本语言吗? 最佳答案 我在Windows上使用Ruby的经验很少,但是当我开始使用Ruby时,我是在Windows上,我的总体印象是它不是Windows原生系统。因此,在主要使用Windows多年之后,开始使用Ruby促使我切换回原来的系统Unix,这次是Linux。Rub

  3. Vscode+Cmake配置并运行opencv环境(Windows和Ubuntu大同小异) - 2

    之前在培训新生的时候,windows环境下配置opencv环境一直教的都是网上主流的vsstudio配置属性表,但是这个似乎对新生来说难度略高(虽然个人觉得完全是他们自己的问题),加之暑假之后对cmake实在是爱不释手,且这样配置确实十分简单(其实都不需要配置),故斗胆妄言vscode下配置CV之法。其实极为简单,图比较多所以很长。如果你看此文还配不好,你应该思考一下是不是自己的问题。闲话少说,直接开始。0.CMkae简介有的人到大二了都不知道cmake是什么,我不说是谁。CMake是一个开源免费并且跨平台的构建工具,可以用简单的语句来描述所有平台的编译过程。它能够根据当前所在平台输出对应的m

  4. 深度学习部署:Windows安装pycocotools报错解决方法 - 2

    深度学习部署:Windows安装pycocotools报错解决方法1.pycocotools库的简介2.pycocotools安装的坑3.解决办法更多Ai资讯:公主号AiCharm本系列是作者在跑一些深度学习实例时,遇到的各种各样的问题及解决办法,希望能够帮助到大家。ERROR:Commanderroredoutwithexitstatus1:'D:\Anaconda3\python.exe'-u-c'importsys,setuptools,tokenize;sys.argv[0]='"'"'C:\\Users\\46653\\AppData\\Local\\Temp\\pip-instal

  5. ruby-on-rails - 使用 HTTParty 的非常基本的 Rails 4.1 API 调用 - 2

    Rails相对较新。我正在尝试调用一个API,它应该向我返回一个唯一的URL。我的应用程序中捆绑了HTTParty。我已经创建了一个UniqueNumberController,并且我已经阅读了几个HTTParty指南,直到我想要什么,但也许我只是有点迷路,真的不知道该怎么做。基本上,我需要做的就是调用API,获取它返回的URL,然后将该URL插入到用户的数据库中。谁能给我指出正确的方向或与我分享一些代码? 最佳答案 假设API为JSON格式并返回如下数据:{"url":"http://example.com/unique-url"

  6. ruby - 如何在 Ruby 中执行 Windows CLI 命令? - 2

    我在目录“C:\DocumentsandSettings\test.exe”中有一个文件,但是当我用单引号编写命令时`C:\DocumentsandSettings\test.exe(我无法在此框中显示),用于在Ruby中执行命令,我无法这样做,我收到的错误是找不到文件或目录。我尝试用“//”和“\”替换“\”,但似乎没有任何效果。我也使用过系统、IO.popen和exec命令,但所有的努力都是徒劳的。exec命令还使程序退出,这是我不想发生的。提前致谢。 最佳答案 反引号环境就像双引号,所以反斜杠用于转义。此外,Ruby会将空格解

  7. ruby - 如何在 Ruby 中生成一个非常大的随机整数? - 2

    我想在ruby​​中生成一个64位整数。我知道在Java中你有很多渴望,但我不确定你会如何在Ruby中做到这一点。另外,64位数字中有多少个字符?这是我正在谈论的示例......123456789999。@num=Random.rand(9000)+Random.rand(9000)+Random.rand(9000)但我认为这是非常低效的,必须有一种更简单、更简洁的方法来做到这一点。谢谢! 最佳答案 rand可以将范围作为参数:pa=rand(2**32..2**64-1)#=>11093913376345012184putsa.

  8. Ruby 服务器在本地主机(teambox)之外非常慢 - 2

    我刚刚在我的Ubuntu9.10服务器上安装了TeamBox。我使用提供的服务器脚本在端口3000上启动并运行它。它的运行速度非常慢,从另一台计算机连接时每个HTTP请求最多需要30秒。我使用链接从shell加载TeamBox,一点也不花时间。然后我设置了一个SSH隧道,它再次运行得非常快。我通过此服务器上的apache以及SAMBA等运行了大约30个虚拟主机,没有任何问题。我该如何解决这个问题? 最佳答案 我的redmine(ruby,webrick)太慢了。现在我解决了这个问题:apt-getinstallmongrelruby

  9. ruby - 错误 : Failed to build gem native extension on Windows - 2

    我在安装“redcarpet”gem时遇到以下错误。它在我friend的机器上安装没有问题。(我想安装它来运行yard)ruby版本:1.9.3命令输出:D:\Learning\Common_POM_FW\SampleProjects>yard[error]:Missing'redcarpet'gemforMarkdownformatting.Installitwith`geminstallredcarpet`D:\Learning\Common_POM_FW\SampleProjects>geminstallredcarpetTemporarilyenhancingPATHtoinc

  10. ruby - 从 Ruby 连接到适用于 Windows Phone 8 的 Microsoft 推送通知服务 - 2

    我们正在开发一个需要推送通知的WP8应用程序。为了测试它,我们使用CURL命令行运行推送通知POST请求,确保它实际连接,使用客户端SSL证书进行身份验证并发送正确的数据。我们确实知道,当我们收到对设备的推送时,这项工作是有效的。这是我们一直用于测试目的的CURL命令:curl--certclient_cert.pem-v-H"Content-Type:text/xml"-H"X-WindowsPhone-Target:Toast"-H"X-NotificationClass:2"-XPOST-d"MytitleMysubtitle"https://db3.notify.live.ne

随机推荐