Asp.net

Visual Studio 中未安裝依賴項

  • June 21, 2016

我目前正在將我的 ASP.Net RC1 升級到 ASP.Net Core RC2。Visual Studio 中的解決方案資源管理器使用子文件夾“npm - 未安裝”向我發出“依賴項 - 未安裝”的警告。

但是,似乎確實安裝了依賴項 - 我在項目目錄中執行了“npm install”,它執行良好,沒有任何錯誤,只是一些警告。它將依賴文件夾添加到一個名為 node-modules 的父文件夾中,我可以在 Windows 資源管理器中清楚地看到它。node-modules 文件夾包含 angular2、bootstrap、copy-webpack-plugin 等文件夾。

有誰知道為什麼 Visual Studio 告訴我他們沒有安裝?我還嘗試從包管理器控制台執行 npm install 並在這些文件夾上執行“右鍵點擊 - > 恢復包”,在解決方案資源管理器中給我警告。

在此處輸入圖像描述

這是我的 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>

我認為該功能應該可以工作,但消息是錯誤的,所以我們可能需要等到他們解決問題。

ASP.NET Core Web Application (.NET Framework 4.5.2)使用Empty ASP.NET Core Template. 在使用 ASP.NET Core Web 應用程序模板創建項目時,它似乎執行正常。

正如操作所提到的,由於安裝了依賴項,因此該消息具有誤導性。似乎只是 Visual Studio 誤報了未安裝 npm 和依賴項。臨時修復是覆蓋 Visual Studio 查找 node.js 的位置,這會刪除 Visual Studio 中的not installed消息。

在 Visual Studio 中,轉到Tools &gt; Options &gt; Projects and Solutions &gt; External Web Tools並添加安裝 node.js 的路徑。預設情況下,它位於C:\Program Files\nodejs\C:\Program Files (x86)\nodejs\將此新行移到頂部或至少在 $(VSINSTALLDIR)\Web\External 行上方。

在此處輸入圖像描述

恢復您的軟體包,錯誤消息應該會消失。

在此處輸入圖像描述

引用自:https://stackoverflow.com/questions/37949833