Dependencies not installed in Visual Studio

2020-02-26 14:33发布

I'm currently upgrading my ASP.Net RC1 to ASP.Net Core RC2. The Solution Explorer in Visual Studio is giving me a warning of "Dependencies - not installed" with subfolder "npm - 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. It added the dependency folders into a parent folder called node-modules which I can see clearly in Windows Explorer. The node-modules folder contains folders for angular2, bootstrap, copy-webpack-plugin, etc.

Does anyone know why Visual Studio is telling me they aren't installed? 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.

enter image description here

Here's my package.json file:

{
  "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"
  }
}

10条回答
你好瞎i
2楼-- · 2020-02-26 15:14

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. VS interprets this as a failure, when it's really not. More details here.

查看更多
在下西门庆
3楼-- · 2020-02-26 15:20

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:

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"

I had to uninstall it with Package Installer tool. Just right click and uninstall package. The NodeJS dependencies error disapeard immediately after.

Reinstall from the CLI by:

npm install packagename

Hope that helps :-)

查看更多
Melony?
4楼-- · 2020-02-26 15:28

Open package.json and start deleting the packages one by one till the warning goes away.

enter image description here

After deleting "webpack": "^1.12.14", from package.json, I no longer get the warning

enter image description here

查看更多
▲ chillily
5楼-- · 2020-02-26 15:29

Project type: 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.

In my case this was jqueryui-amd:

remote: Repository not found. fatal: repository 'https://github.com/jrburke/jqueryui-amd.git/' not found

Remove the failing dependency and right-click Dependencies "folder" in the solution base path and choose

Restore packages
查看更多
放荡不羁爱自由
6楼-- · 2020-02-26 15:30

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.

查看更多
Animai°情兽
7楼-- · 2020-02-26 15:31

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. 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.

problem_child

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.

For me it was the ckokidar module, however it was located in two places.

MYPROJECT\node_modules\chokidar

and also in

MYPROJECT\node_modules\browser-sync\node_modules\chokidar

I suspect if you have gulp-watch as a dependency it might be there as well.

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.

"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.

Finally, right click in Visual Studio on the Dependencies and run Restore Packages. You should now be warning free! Enjoy.

result

查看更多
登录 后发表回答