读取包时出错:graceful-fs \ package.json

时间:2015-10-26 10:04:03

标签: node.js cordova npm ionic

我最近安装了Node.js,npm,ionic和cordova,如Ionic Getting Started所述

现在,当我打开Visual Studio项目时,Bower / NPM窗口显示以下错误:

  

System.AggregateException:发生了一个或多个错误。 --->   Microsoft.NodejsTools.Npm.PackageJsonException:读取错误   package.json at   ' C:\用户\科林\应用程序数据\漫游\ NPM \ node_modules \科尔多瓦\ node_modules \ NPM \ node_modules \优美-FS \的package.json&#39 ;:   读取package.json时出错。该文件可能是可解析的JSON,但可能   包含具有重复属性的对象。

这似乎是由于problem with the npm package。那么我该如何解决这个问题呢?我是否安装了早期版本的Node,npm,cordova或graceful-fs?我该怎么做?

修改 根据Vikas Vats的评论,我运行了以下命令:

cordova -v我告诉我的全球版本是5.3.3

npm uninstall -g cordova

npm install -g cordova@4.3.0

我现在收到graceful-fs\package.json中报告的相同错误,但这次它位于不同的位置:

  

C:\用户\科林\应用程序数据\漫游\ NPM \ node_modules \离子\ node_modules \离子-APP-LIB \ node_modules \离子-科尔多瓦-LIB \ node_modules \ NPM \ node_modules \优美-FS \的package.json < / p>

2 个答案:

答案 0 :(得分:0)

来自https://github.com/npm/npm/issues/9965

在文本编辑器中打开C:\Users\Colin\AppData\Roaming\npm\node_modules\ionic\node_modules\ionic-app-lib\node_modules\ionic-cordova-lib\node_modules\npm\node_modules\graceful-fs\package.json并删除重复的根密钥:

  • 发动机
  • gitHead
  • 虫子
  • 主页
  • _id
  • _shasum
  • _from
  • _npmVersion
  • _nodeVersion
  • _npmUser
  • DIST
  • 存储库
  • 版本

根密钥只能在package.json

中出现一次

答案 1 :(得分:0)

我卸载了cordova - 将其恢复到Visual Studio版本已经过测试:

npm uninstall -g cordova

npm install -g cordova@4.3.0

这将错误移至离子。所以我把Ionic带回1.6.5版本:

npm uninstall -g ionic

npm install -g ionic@1.6.5

这修复了graceful-fs / package.json文件。我在这里复制了这些内容:

{
  "author": {
    "name": "Isaac Z. Schlueter",
    "email": "i@izs.me",
    "url": "http://blog.izs.me"
  },
  "name": "graceful-fs",
  "description": "A drop-in replacement for fs, making various improvements.",
  "version": "2.0.0",
  "repository": {
    "type": "git",
    "url": "git://github.com/isaacs/node-graceful-fs.git"
  },
  "main": "graceful-fs.js",
  "engines": {
    "node": ">=0.4.0"
  },
  "directories": {
    "test": "test"
  },
  "scripts": {
    "test": "tap test/*.js"
  },
  "keywords": [
    "fs",
    "module",
    "reading",
    "retry",
    "retries",
    "queue",
    "error",
    "errors",
    "handling",
    "EMFILE",
    "EAGAIN",
    "EINVAL",
    "EPERM",
    "EACCESS"
  ],
  "license": "BSD",
  "readme": "# graceful-fs\n\ngraceful-fs functions as a drop-in replacement for the fs module,\nmaking various improvements.\n\nThe improvements are meant to normalize behavior across different\nplatforms and environments, and to make filesystem access more\nresilient to errors.\n\n## Improvements over fs module\n\ngraceful-fs:\n\n* keeps track of how many file descriptors are open, and by default\n  limits this to 1024. Any further requests to open a file are put in a\n  queue until new slots become available. If 1024 turns out to be too\n  much, it decreases the limit further.\n* fixes `lchmod` for Node versions prior to 0.6.2.\n* implements `fs.lutimes` if possible. Otherwise it becomes a noop.\n* ignores `EINVAL` and `EPERM` errors in `chown`, `fchown` or\n  `lchown` if the user isn't root.\n* makes `lchmod` and `lchown` become noops, if not available.\n* retries reading a file if `read` results in EAGAIN error.\n\nOn Windows, it retries renaming a file for up to one second if `EACCESS`\nor `EPERM` error occurs, likely because antivirus software has locked\nthe directory.\n\n## Configuration\n\nThe maximum number of open file descriptors that graceful-fs manages may\nbe adjusted by setting `fs.MAX_OPEN` to a different number. The default\nis 1024.\n",
  "readmeFilename": "README.md",
  "bugs": {
    "url": "https://github.com/isaacs/node-graceful-fs/issues"
  },
  "_id": "graceful-fs@2.0.0",
  "_from": "graceful-fs@2"
}

我还尝试了下一个Ionic版本 - 1.7.0和最近的版本 - 1.7.7。问题又回来了,所以我现在坚持1.6.5

参考 Ionic releases