4

Inherited a broken NLog project from a long-gone co-worker...

  • VS2015 update 2
  • Latest Node install
  • Latest npm update 3.10.3
  • '.net 5.0' project (pre-core 1.0)

My npm node always says 'npm - not installed'

NPM not installed

When I right click, I instantly get 'illegal characters in path'

enter image description here

here's my package.json

{
"version": "0.0.0",
"name": "asp.net",
"devDependencies": {
    "gulp": "^3.9.0",
    "gulp-bower": "^0.0.11",
    "gulp-concat": "^2.6.0",
    "gulp-install": "^0.6.0",
    "gulp-sass": "^2.1.1",
    "gulp-uglify": "^1.5.1",
    "gulp-util": "^3.0.7",
    "gulp-watch": "^4.3.5",
    "run-sequence": "^1.1.5",
    "browser-sync": "^2.10.0",
    "gulp-filter": "^3.0.1",
    "main-bower-files": "^2.9.0",
    "gulp-rename": "^1.2.2",
    "gulp-sourcemaps": "^1.6.0"
}

here's my project.json:

{
"webroot": "wwwroot",
"version": "1.0.0-*",
"dependencies": {
    "EntityFramework.Commands": "7.0.0-rc1-final",
    "EntityFramework.MicrosoftSqlServer": "7.0.0-rc1-final",
    "Microsoft.AspNet.Authentication.Cookies": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics": "1.0.0-rc1-final",
    "Microsoft.AspNet.Diagnostics.Entity": "7.0.0-rc1-final",
    "Microsoft.AspNet.Identity.EntityFramework": "3.0.0-rc1-final",
    "Microsoft.AspNet.IISPlatformHandler": "1.0.0-rc1-final",
    "Microsoft.AspNet.Mvc": "6.0.0-rc1-final",
    "Microsoft.AspNet.Mvc.TagHelpers": "6.0.0-rc1-final",
    "Microsoft.AspNet.Server.Kestrel": "1.0.0-rc1-final",
    "Microsoft.AspNet.Server.WebListener": "1.0.0-rc1-final",
    "Microsoft.AspNet.Session": "1.0.0-rc1-final",
    "Microsoft.AspNet.SignalR.Server": "3.0.0-rc1-final",
    "Microsoft.AspNet.StaticFiles": "1.0.0-rc1-final",
    "Microsoft.AspNet.Tooling.Razor": "1.0.0-rc1-final",
    "Microsoft.Extensions.Caching.Memory": "1.0.0-rc1-final",
    "Microsoft.Extensions.Configuration.Json": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Console": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.Debug": "1.0.0-rc1-final",
    "Microsoft.Extensions.Logging.NLog": "1.0.0-rc1-final",
    "Microsoft.VisualStudio.Web.BrowserLink.Loader": "14.0.0-rc1-final",
    "MvcWebApiCors": "0.3.0"
},
"commands": {
    "web": "Microsoft.AspNet.Server.Kestrel",
    "ef": "EntityFramework.Commands"
},
"frameworks": {
    "dnx451": {
  "dependencies": {
    "Rally.RestApi": "1.0.0-*"
  }
    }
},
"exclude": [
    "wwwroot",
    "node_modules",
    "bower_components"
],
"publishExclude": [
    "node_modules",
    "bower_components",
    "**.kproj",
    "**.user",
    "**.vspscc"
],
"scripts": {
    "postrestore": [ "npm install" ],
    "prepare": [ "gulp" ]
}

Here's my Bower.json

{
"name": "WebApplication",
"private": true,
"dependencies": {
    "bootstrap": "^4.0.0-alpha.2",
    "signalr": "^2.2.0",
    "font-awesome": "^4.5.0",
    "moment": "^2.11.0",
    "Chart-js": "^1.0.2",
    "tether": "^1.1.1",
    "bootstrap-daterangepicker": "2.1.17",
    "handlebars": "^4.0.5",
    "chosen": "^1.4.2"
}

global.json

{
"projects": [
"src",
"wrap"
],
"sdk": {
"version": "1.0.0-rc1-update1"
}

The overall problem is that none of the css/styles are showing. The site looks skeletal compared to what's on our iis box.

Beau D'Amore
  • 3,174
  • 5
  • 24
  • 56
  • Do you have spaces or dashes `-` in your (project's) path name? – Tseng Jun 28 '16 at 14:45
  • "project's path name"?.. – Beau D'Amore Jun 28 '16 at 15:32
  • if I remove "gulp-watch": "^4.3.5" and "browser-sync": "^2.10.0" the err goes away, fyi – Beau D'Amore Jun 28 '16 at 15:33
  • This do not answer my question. Do you have a space or a dash in the folder path where your project is located? i.e. do you have folder names like "C:\Projects\some-stuff\MyProject" or "C:\Projects with space\MyProject"? Some command line tools may have issues with such folders – Tseng Jun 28 '16 at 15:50
  • Make sure you have `Path` Environment Variable set for `npm`. Also make sure it ends with `;` – Venkata Dorisala Jun 28 '16 at 15:58
  • no, there are no spaces in any local path for the files/folders. In vs/tools/options/projects and solutions/external web tools/ I added 'c:\program files (x86)\nodejs' as well... – Beau D'Amore Jun 28 '16 at 18:36
  • just updated to asp.net core 1.0 release (came out last night) and vs update 3, same errors – Beau D'Amore Jun 28 '16 at 18:36

2 Answers2

4

Faced the same issue when tried to install an npm package globally (with -g flag). Any npm package which I tried to install globally was throwing the same error given below.

npm ERR! code EINVAL
npm ERR! path C:\Users\xxxxxxx'C:\Users\xxxxxxx\AppData\Roaming\npm
npm ERR! Illegal characters in path.

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\xxxxxxx\AppData\Local\npm-cache\_logs\2021-12-15T10_49_39_874Z-debug.log

I checked the PATH variable. All is well.

After some research over the internet, tried the following command

npm bin -g

This showed a weird path.

C:\Users\xxxxxx'C:\Users\xxxxxx\AppData\Roaming\npm
(not in PATH env variable)

After reading this post, I tried to set the path prefix of npm config and it worked!

This is how I set it.

npm config set prefix C:\Users\xxxxxxx\AppData\Roaming\npm

You can check & confirm the same using,

npm config get prefix

Ideally, this path was getting added to the '.npmrc' file in my home directory (C:\Users\xxxxxxx). If you don't have any other content in the '.npmrc' file (like an access token to your private npm registry), deleting the file will fix this issue.

Just posting here, so that someone facing similar issue might find this helpful as the question title relates to this issue.

Vijay Sarin
  • 1,326
  • 1
  • 11
  • 31
2

Found the answer...

Some packages (for instance webpack) have dependency on packages that are not supported on windows which causes NPM to print warning about it. VS interprets it as generic problem and says that packages are not installed even though in reality this warning should be ignored.

Beau D'Amore
  • 3,174
  • 5
  • 24
  • 56