在Visual Studio中未安装的依赖项

我目前正在将我的ASP.Net RC1升级到ASP.Net Core RC2。 Visual Studio中的解决scheme资源pipe理器给我一个警告:“依赖关系 – 未安装”子文件夹“npm – 未安装”。

然而,依赖关系似乎被安装 – 我在项目目录中运行“npm install”,它运行良好,没有任何错误,只是一些警告。 它将依赖关系文件夹添加到一个名为node-modules的父文件夹中,我可以在Windows资源pipe理器中清楚地看到它们。 node-modules文件夹包含用于angular2,bootstrap,copy-webpack-plugin等的文件夹。

有谁知道为什么Visual Studio告诉我他们没有安装? 我也尝试从软件包pipe理器控制台运行npm install,并在解决scheme资源pipe理器中对这些文件夹执行“右键单击 – >恢复软件包”的警告。

在这里输入图像描述

这是我的package.json文件:

{ "name": "EmptyWebApp", "version": "0.0.0", "dependencies": { "angular2": "2.0.0-beta.13", "bootstrap": "^3.3.5", "es6-promise": "^3.0.2", "es6-shim": "^0.35.0", "reflect-metadata": "0.1.2", "jquery": "^2.1.4", "less": "^2.5.3", "lodash": "^3.10.1", "rxjs": "5.0.0-beta.2", "systemjs": "0.19.22", "ts-loader": "^0.7.2", "zone.js": "0.6.6" }, "devDependencies": { "del": "^2.0.2", "event-stream": "^3.3.1", "copy-webpack-plugin": "^0.3.3", "css-loader": "^0.23.0", "exports-loader": "0.6.2", "expose-loader": "^0.7.1", "file-loader": "^0.8.4", "gulp": "^3.9.0", "html-webpack-plugin": "^1.7.0", "http-server": "^0.8.5", "imports-loader": "^0.6.4", "istanbul-instrumenter-loader": "^0.1.3", "json-loader": "^0.5.3", "nodemon": "^1.8.1", "phantomjs": "^1.9.18", "phantomjs-polyfill": "0.0.1", "protractor": "^3.0.0", "raw-loader": "0.5.1", "reflect-metadata": "0.1.2", "remap-istanbul": "^0.5.1", "rimraf": "^2.4.4", "style-loader": "^0.13.0", "ts-helper": "0.0.1", "ts-loader": "^0.7.2", "tsconfig-lint": "^0.4.3", "tslint": "^3.2.0", "tslint-loader": "^2.1.0", "typedoc": "^0.3.12", "typescript": "1.8.9", "typings": "^0.6.1", "url-loader": "^0.5.6", "webpack": "^1.12.9", "webpack-dev-server": "^1.12.1", "webpack-md5-hash": "0.0.4" }, "scripts": { "tsc": "tsc -p . -w", "start": "nodemon --ignore htm,html --ext cs,js --exec \"dnx web\" -V", "static": "nodemon --watch ./client --ext html,css --exec \"gulp deploy-client\" -V", "pre-build": "gulp deploy-client", "webpack": "webpack", "webpack-watch": "webpack --watch", "clean": "gulp cleanwww", "build": "npm run pre-build && npm run webpack", "dnx": "dnx web" } } 

我认为这是在asp的github报道的RC2已知的问题

https://github.com/aspnet/Tooling/issues/479

我认为function应该可以工作,但是信息是错误的,所以我们可能需要等到他们解决问题。

在使用Empty ASP.NET Core Template创buildASP.NET Core Web Application (.NET Framework 4.5.2)时,这仍然是Visual Studio Community 2015 Update 3版本中的一个问题。 它使用ASP.NET核心Web应用程序模板创build项目时似乎正常工作。

正如上面提到的那样,由于安装了依赖关系,所以这个消息是误导性的。 这似乎只是由Visual Studio错误报告npm和依赖没有安装。 临时解决方法是重写Visual Studio查找node.js的位置,这将删除visual studio中not installed消息。

在Visual Studio中,转至Tools > Options > Projects and Solutions > External Web Tools然后添加一个path到您的node.js. 这是默认位于C:\Program Files\nodejs\C:\Program Files (x86)\nodejs\将此新行移到顶部或至less在$(VSINSTALLDIR)\ Web \ External行之上。

在这里输入图像描述

恢复你的软件包,错误信息应该消失。

在这里输入图像描述

这似乎是由于NPM产生了一个关于无法安装的组件的警告,例如,如果你是在Windows上的OSX组件。 VS解释这是一个失败,当它不是。 更多细节在这里。

我有同样的问题,并通过添加C:\Program Files\Nodejs到我的外部Web工具path当前最高的投票答案没有做任何事情 。 即使改变path的顺序也没有帮助。

 >npm - v 4.2.0 >node - v v6.10.0 

从技术上讲,你可以在Visual Studio中扩展你的依赖关系树,以最终find问题,但是,它更容易运行npm list并find问题的孩子。

问题少年

因此,由于fsevents是罪魁祸首,它是一个可选的依赖项(当在windows体系结构上运行visual studio时不使用它),我find了fsevents作为可选依赖项的模块。

对我来说,这是ckokidar模块,但是它位于两个地方。

MYPROJECT \ node_modules \ chokidar

也在

MYPROJECT \ node_modules \浏览器同步\ node_modules \ chokidar

我怀疑,如果你有吞咽作为一个依赖它也可能在那里。

所以我所做的是为每个文件夹打开project.json文件,并删除其中的任何fsevents轨道。

 "dependencies": { .... "async-each": "^1.0.0", <-- also remember to remove the trailing ',' comma for the end "fsevents": "^1.0.0" <-- remove this } 

 "keywords": [ ... "file", <-- remove comma "fsevents" <-- remove ], 

并完全删除它

 "optionalDependencies": { "fsevents": "^1.0.0" }, 

不要在任何文件中留下任何尾随的逗号,否则你会从npm中得到一个错误。

最后,右键单击依赖项上的Visual Studio并运行Restore Packages 。 你现在应该是免费的警告! 请享用。

结果

我从package.json文件中删除了每个项目,直到错误停止显示。 在我的情况下,错误是由…造成的

“grunt-ts”:“5.5.1”

打开package.json并开始逐个删除包,直到警告消失。

在这里输入图像描述

从package.json中删除"webpack": "^1.12.14",后,我不再收到警告

在这里输入图像描述

只需将node-js文件夹中的node-modules文件夹复制并粘贴到您的visual studio,项目根文件夹,然后右键单击并恢复VS中的包。 这将做的伎俩!

我遵循了David Glass的build议,尽pipe它看起来仍然有问题。 我更新了我的package.json文件,以便devDependencies匹配依赖关系,然后警告就消失了。

项目types:ASP.NET核心(.NET)

如果您的脚本依赖项无法安装,也会发生这种情况。 VS输出窗口将显示相应的错误。

在我的情况下,这是jquerui-amd:

远程:找不到存储库。 致命的:存储库
找不到“ https://github.com/jrburke/jqueryui-amd.git/

删除失败的依赖项,然后右键单击解决scheme基本path中的依赖项“文件夹”并select

还原包

我的问题是阻止所有其他软件包加载的软件包之一,查看所有您的软件包是否启动命令行界面“CMD”并导航到您的项目 – >types:

npm install

你会看到,如果你所有的数据包通过安装没有问题。

我的软件包有问题

Webpack“Webpack”:“^ 1:12:14”

我不得不使用Package Installer工具卸载它。 只需右键单击并卸载软件包。 NodeJS依赖关系错误立即消失。

通过以下方式从CLI重新安装:

npm安装软件包名称

希望有帮助:-)