Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

npm - not installed; illegal characters in path

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.

like image 551
Beau D'Amore Avatar asked Oct 30 '25 00:10

Beau D'Amore


1 Answers

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.

like image 51
Vijay Sarin Avatar answered Nov 01 '25 15:11

Vijay Sarin