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

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

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

System.AggregateException:发生一个或多个错误。 —> Microsoft.NodejsTools.Npm.PackageJsonException:在C:\ Users \ Colin \ AppData \ Roaming \ npm \ node_modules \ cordova \ node_modules \ npm \ node_modules \ graceful-fs \ package.json中读取package.json错误:读取package.json时出错。 该文件可能是可parsing的JSON,但可能包含具有重复属性的对象。

这似乎是由于npm包的问题 。 那么我该如何解决这个问题呢? 我是否安装早期版本的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:\ Users \用户科林\应用程序数据\漫游\ NPM \ node_modules \离子\ node_modules \离子-APP-LIB \ node_modules \离子-cordova-LIB \ node_modules \ NPM \ node_modules \优美-FS \的package.json

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
  • _从
  • _npmVersion
  • _nodeVersion
  • _npmUser
  • DIST
  • 知识库

根键只能在package.json出现一次

我卸载了cordova – 回到Visual Studio的版本已经过testing:

 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

参考离子版本