简体   繁体   English

Visual Studio中未安装依赖项

[英]Dependencies not installed in Visual Studio

I'm currently upgrading my ASP.Net RC1 to ASP.Net Core RC2. 我目前正在将ASP.Net RC1升级到ASP.Net Core RC2。 The Solution Explorer in Visual Studio is giving me a warning of "Dependencies - not installed" with subfolder "npm - not installed". Visual Studio中的解决方案资源管理器通过子文件夹“npm - not installed”向我发出“Dependencies - not installed”的警告。

However, the dependencies do seem to be installed - I ran 'npm install' in the project directory and it ran fine without any errors, just some warnings. 但是,似乎安装了依赖项 - 我在项目目录中运行'npm install'并且运行正常,没有任何错误,只是一些警告。 It added the dependency folders into a parent folder called node-modules which I can see clearly in Windows Explorer. 它将依赖项文件夹添加到名为node-modules的父文件夹中,我可以在Windows资源管理器中清楚地看到它。 The node-modules folder contains folders for angular2, bootstrap, copy-webpack-plugin, etc. node-modules文件夹包含angular2,bootstrap,copy-webpack-plugin等文件夹。

Does anyone know why Visual Studio is telling me they aren't installed? 有谁知道为什么Visual Studio告诉我他们没有安装? I've also tried running npm install from Package Manager Console and doing a 'right-click -> restore packages' on those folders giving me the warning in the Solution Explorer. 我还尝试从Package Manager Console运行npm install,并在这些文件夹上执行“右键单击 - >还原包”,在解决方案资源管理器中给出警告。

在此输入图像描述

Here's my package.json file: 这是我的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"
  }
}

This is still an issue in Visual Studio Community 2015, Update 3 edition when creating an ASP.NET Core Web Application (.NET Framework 4.5.2) using the the Empty ASP.NET Core Template . 在使用Empty ASP.NET Core Template创建ASP.NET Core Web Application (.NET Framework 4.5.2)时,这仍然是Visual Studio Community 2015,Update 3版本中的一个问题。 It does appear to function properly when creating the project using the ASP.NET Core Web Application Template. 使用ASP.NET Core Web应用程序模板创建项目时,它似乎正常运行。

As the op mentioned the message is misleading since the dependencies are installed. 正如操作中提到的那样,由于安装了依赖项,因此该消息具有误导性。 It seems to be just a misreporting by Visual Studio that the npm and the dependencies are not installed. Visual Studio似乎只是误报了npm和依赖项没有安装。 The temporary fix is to override where Visual Studio is looking for node.js, which removes the not installed messages in visual studio. 临时修复是覆盖Visual Studio正在寻找node.js的位置,这将删除visual studio中not installed消息。

In Visual Studio go to Tools > Options > Projects and Solutions > External Web Tools and add a path to your installation of node.js. 在Visual Studio中,转到“ Tools > Options > Projects and Solutions > External Web Tools然后添加node.js安装的路径。 This is by default located at C:\\Program Files\\nodejs\\ or C:\\Program Files (x86)\\nodejs\\ Move this new line to the top or at least above the $(VSINSTALLDIR)\\Web\\External line. 默认位于C:\\Program Files\\nodejs\\C:\\Program Files (x86)\\nodejs\\将此新行移至顶部或至少高于$(VSINSTALLDIR)\\ Web \\ External行。

在此输入图像描述

Restore your packages and the error message should go away. 恢复您的包,错误消息应该消失。

在此输入图像描述

I think this is known problem with RC2 reported in asp github 我认为这是在asp github上报道的RC2的已知问题

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

I think the functionality should work but the message is wrong so probably we need to wait until they solve the problem. 我认为功能应该可行,但消息是错误的,所以我们可能需要等到他们解决问题。

This appears to be due to the fact that NPM produces a warning about a component that cannot be installed, such as an OSX component if you're on windows. 这似乎是由于NPM对无法安装的组件发出警告,例如OSX组件(如果您在Windows上)。 VS interprets this as a failure, when it's really not. VS将其解释为失败,而实际上并非如此。 More details here. 更多细节在这里。

I had the same problem, and following the current highest voted answer by adding C:\\Program Files\\Nodejs to my External Web Tools paths did not do anything . 我遇到了同样的问题,并通过将C:\\Program Files\\Nodejs到我的外部Web工具路径而遵循当前最高投票答案没有做任何事情 Even changing the order of paths didn't help. 即使改变路径的顺序也无济于事。

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

Technically you can expand your dependencies tree in visual studio to eventually find the problem, however, its easier to just run npm list and find the problem child. 从技术上讲,您可以在visual studio中扩展依赖关系树以最终找到问题,但是,更容易运行npm list并找到问题子项。

问题少年

So since fsevents was the culprit and it was an optional dependency (its not used when running node with visual studio on windows architecture), I located the modules that had fsevents as an optional dependency. 因为fsevents是罪魁祸首,它是一个可选的依赖项(在Windows体系结构上使用visual studio运行节点时不使用它),我将具有fsevents的模块定位为可选依赖项。

For me it was the ckokidar module, however it was located in two places. 对我来说它是ckokidar模块,但它位于两个地方。

MYPROJECT\\node_modules\\chokidar MYPROJECT \\ node_modules \\ chokidar

and also in 还有

MYPROJECT\\node_modules\\browser-sync\\node_modules\\chokidar MYPROJECT \\ node_modules \\浏览器同步\\ node_modules \\ chokidar

I suspect if you have gulp-watch as a dependency it might be there as well. 我怀疑你是否有gulp-watch作为依赖,它也可能存在。

So what I did is for each one of those folders, I opened the project.json file and removed any track of fsevents in them. 所以我做的是每个文件夹,我打开了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
}

and

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

and remove this completely 并完全删除它

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

Don't leave any trailing commas in any of the files or you will get an error from npm. 不要在任何文件中留下任何尾随逗号,否则你将从npm收到错误。

Finally, right click in Visual Studio on the Dependencies and run Restore Packages . 最后,右键单击Dependencies上的Visual Studio并运行Restore Packages You should now be warning free! 你现在应该免费警告! Enjoy. 请享用。

结果

I removed each item from the package.json file until the error stops appearing. 我从package.json文件中删除了每个项目,直到错误停止出现。 In my case the error was caused by 在我的情况下,错误是由

"grunt-ts": "5.5.1" “grunt-ts”:“5.5.1”

Open package.json and start deleting the packages one by one till the warning goes away. 打开package.json并开始逐个删除软件包,直到警告消失。

在此输入图像描述

After deleting "webpack": "^1.12.14", from package.json, I no longer get the warning 从package.json删除"webpack": "^1.12.14",后,我不再收到警告

在此输入图像描述

Just copy and paste node-modules folder from nodejs folder to your visual studio, project root folder, and right click and restore packages inside VS . 只需将node-modules文件夹中的node-modules文件夹复制并粘贴到visual studio,项目根文件夹,然后右键单击并恢复VS中的软件包即可。 That will do the trick! 那就行了!

I followed the advice of David Glass, although it still looked like I had an issue. 我遵循大卫玻璃的建议,虽然看起来我仍然有问题。 I updated my package.json file so that the devDependencies matched the dependencies and then the warning went away. 我更新了我的package.json文件,以便devDependencies与依赖项匹配,然后警告就消失了。

Project type: ASP.NET Core (.NET) 项目类型:ASP.NET Core(.NET)

This can also happen if you have a script dependency that failed to install. 如果您的脚本依赖项无法安装,也会发生这种情况。 The VS Output window will show the respective error. VS Output窗口将显示相应的错误。

In my case this was jqueryui-amd: 在我的情况下,这是jqueryui-amd:

remote: Repository not found. remote:找不到存储库。 fatal: repository ' https://github.com/jrburke/jqueryui-amd.git/ ' not found 致命:未找到存储库' https://github.com/jrburke/jqueryui-amd.git/ '

Remove the failing dependency and right-click Dependencies "folder" in the solution base path and choose 删除失败的依赖关系,右键单击解决方案基本路径中的Dependencies“folder”,然后选择

Restore packages

My problem was one of the packages that stopped all other packages from loading, the best way to see if all your packages that work is to start the command line interface "CMD" and navigate to your project -> Type: 我的问题是阻止所有其他软件包加载的软件包之一,这是查看所有软件包是否可以启动命令行界面“CMD”并导航到项目的最佳方法 - >类型:

npm install

and you will see if all your packets go through the installation without problems. 并且您将看到所有数据包是否都没有问题地通过安装。

The package I had problems with the 包裹我遇到了问题

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

I had to uninstall it with Package Installer tool . 我不得不使用Package Installer工具卸载它。 Just right click and uninstall package. 只需右键单击并卸载包。 The NodeJS dependencies error disapeard immediately after. NodeJS依赖关系错误之后立即消失。

Reinstall from the CLI by: 通过以下方式从CLI重新安装:

npm install packagename npm install packagename

Hope that helps :-) 希望有所帮助:-)

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 MSBuild 16 在没有安装 Visual Studio 的情况下不会发布 - MSBuild 16 is not publishing without visual studio installed 现在可以在不依赖Visual Studio的情况下生成模板了吗? - Template can now be generated without visual studio dependencies? Bamboo CI 构建的 Visual Studio 解决方案,具有构建顺序依赖项 - Bamboo CI build of Visual Studio solution with build order dependencies Visual Studio 认为 NuGet 包已安装但未安装 - Visual Studio thinks NuGet packages are installed that aren't 如何重新加载安装在Visual Studio解决方案中的umbraco? - How Can I reload the umbraco installed in my visual studio solution? 没有Visual Studio的msbuild(是,已安装Windows SDK并且Copy Local = true) - msbuild with no Visual Studio (Yes Windows SDK installed & Copy Local=true) 已安装Visual Studio 2013 for Web,但在开始菜单中不存在 - Visual Studio 2013 for web installed but not present in start menu .NET Framework 4.0是否作为Visual Studio 2010安装的一部分安装? - Is .NET Framework 4.0 installed as part of Visual Studio 2010 install? 在Visual Studio中打开网站时,“未安装Project Target Framework” - “Project Target Framework Not Installed” when opening a web site in Visual Studio 哪些版本的ASP.NET与Visual Studio 2010一起安装? - Which versions of ASP.NET gets installed with Visual Studio 2010?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM