madskristensen / NpmTaskRunner

Visual Studio extension
Other
88 stars 32 forks source link

Can't download package `@angular/common`(package with @ symbol) #44

Closed pankajparkar closed 7 years ago

pankajparkar commented 7 years ago

It seems to be a bug.

Installed product versions

Description

I'm trying to install angular 2 packages using NPM Task Runner. angular package has @angular/common, @angular/core, @angular/upgrade, @angular/forms.etc. When I tried to install the packages using Restore Package option.

It throws an error below error

npm http 404 https://registry.npmjs.org/angular/common npm http 404 https://registry.npmjs.org/angular/compiler npm http 404 https://registry.npmjs.org/angular/core npm http 404 https://registry.npmjs.org/angular/forms ... ...

====npm command completed with exit code 1====

If you look at output closely, what I observed is while running npm commands it removes @(symbol) from package name. That's the reason package doesn't get install.

Steps to recreate

  1. Add below configuration in package.json dependencies option
    "@angular/common": "^2.4.1",
    "@angular/compiler": "~2.4.1",
    "@angular/core": "~2.4.1",
    "@angular/forms": "~2.4.1",
  2. Right click on package.json and run a build from "Task Runner Explorer"(also tried restore package option)
  3. check "Task Runner Output" window.(It does show above mentioned errors).

Expected behavior

It should download @angular/common package, I mean package with @ symbol.

scottaddie commented 7 years ago

Please run the following command, and reply with the version numbers that you see:

node -v && npm -v

I'm unable to reproduce on my machine, and I'm using Node 6.9.1 and npm 4.0.5 with VS 2015 Update 3.

One setting to check in VS 2015 is Tools --> Options --> Projects and Solutions --> External Web Tools. Make sure that the $(PATH) entry is the 2nd one in the list of 4.

pankajparkar commented 7 years ago

That got worked. Thanks @scottaddie

Could you please tell me, why npm download all unnecessary packages in my node_modules folder?

I expected it to show only mentioned packages inside package.json.

Any thoughts?

scottaddie commented 7 years ago

As of npm v3, there's no longer a 1-to-1 mapping between dependencies/devDepdendencies in package.json and folders in node_modules. Specifically, this version of npm flattens dependencies as they're installed. This feature is intended to save Windows users from the MAX_PATH character limitation that was encountered in npm v2.

Take, for example, the following package.json file:

{
  "version": "1.0.0",
  "name": "asp.net",
  "private": true,
  "dependencies": {
    "@angular/common": "^2.4.1",
    "@angular/compiler": "~2.4.1",
    "@angular/core": "~2.4.1",
    "@angular/forms": "~2.4.1"
  },
  "devDependencies": {
    "webpack": "1.14.0"
  }
}

You'll see the following contents in node_modules after running npm install:

node_modules

With the exception of node_modules/@angular, the other folders are required for Webpack.

pankajparkar commented 7 years ago

@scottaddie Thanks for clarification :+1: , It has cleared my concept.