Can't recover from misspelt vue-cli 'npm' command 'nom'

vue-cli

#1

I am creating a @vue/cli 3.x. project using

$ sudo vue create vue-cli3-axios-api-uinames

The development server runs fine with,

$ npm run serve

But on occassion I misspell npm with ‘nom’

$ nom install

instead of the intended,

$ npm install

which should install all packages in package.json

This gives a huge error the first four lines of which look like this,

$ nom install
rm: node_modules/indexes-of/.npmignore: Permission denied
rm: node_modules/indexes-of/test.js: Permission denied
rm: node_modules/indexes-of/LICENSE: Permission denied
rm: node_modules/indexes-of/index.js: Permission denied..........
................................................................................

If I make this mistake I can’t get the project working again without removing the directory and creating the whole project again.

Trying to run the server after the misspelt command this gives,

$ npm run serve
> vue-cli3-axios-api-uinames@0.1.0 serve /Users/shanegibney/vue-cli3-axios-api-uinames
> vue-cli-service serve
sh: vue-cli-service: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! vue-cli3-axios-api-uinames@0.1.0 serve: `vue-cli-service serve`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the vue-cli3-axios-api-uinames@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/shanegibney/.npm/_logs/2019-01-14T15_53_50_767Z-debug.log

But ‘nom’ is not a command recognised by

$ man nom

Also,

$ which nom

returns nothing

Is there such a command as ‘nom’ and why does it have such an effect on my @vue/cli project?

There is an npm package called ‘nom’ but I’ve never installed it so it should not have any effect here.

At this stage package.json still looks like this,

{
  "name": "vue-cli3-axios-api-uinames",
  "version": "0.1.0",
  "private": true,
  "scripts": {
    "serve": "vue-cli-service serve",
    "build": "vue-cli-service build",
    "lint": "vue-cli-service lint"
  },
  "dependencies": {
    "vue": "^2.5.21"
  },
  "devDependencies": {
    "@vue/cli-plugin-babel": "^3.3.0",
    "@vue/cli-plugin-eslint": "^3.3.0",
    "@vue/cli-service": "^3.3.0",
    "babel-eslint": "^10.0.1",
    "eslint": "^5.8.0",
    "eslint-plugin-vue": "^5.0.0",
    "vue-template-compiler": "^2.5.21"
  },
  "eslintConfig": {
    "root": true,
    "env": {
      "node": true
    },
    "extends": [
      "plugin:vue/essential",
      "eslint:recommended"
    ],
    "rules": {},
    "parserOptions": {
      "parser": "babel-eslint"
    }
  },
  "postcss": {
    "plugins": {
      "autoprefixer": {}
    }
  },
  "browserslist": [
    "> 1%",
    "last 2 versions",
    "not ie <= 8"
  ]
}

To get the project back working, I have tried,

$ sudo npm install

Password:

npm WARN ajv-keywords@2.1.1 requires a peer of ajv@^5.0.0 but none is installed. You must install peer dependencies yourself.
added 1 package from 1 contributor, updated 137 packages and audited 15221 packages in 9.952s
found 0 vulnerabilities

At this stage it seems as though it should work fine. However when I try to run the dev server again and I get the same error message,

$ sudo npm run serve
vue-cli3-axios-api-uinames@0.1.0 serve /Users/shanegibney/vue-cli3-axios-api-uinames
vue-cli-service serve
sh: vue-cli-service: command not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! vue-cli3-axios-api-uinames@0.1.0 serve: `vue-cli-service serve`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the vue-cli3-axios-api-uinames@0.1.0 serve script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/shanegibney/.npm/_logs/2019-01-14T18_55_36_711Z-debug.log

Versions I am using are as follows:
node 10.15.0
vue 3.3.0
npm 6.4.1
MacOS Mojave 10.14.2

Any help would be greatly appreciated,

Thanks


#2

That’s super weird. Never heard of a command called nom and it certainly isn’t from to vue-cli


#3

Yes weird and very inconvenient. Actually it is effecting all my projects at the moment.

Anyway thanks for looking at it and confirming that it isn’t anything simple or obvious that is causing this.

Perhaps i could try making an alias of nom, as suggested here https://devrant.com/rants/950392/forever-typing-nom-install


#4

I found the problem,

alias nom='rm -rf node_modules && npm cache clear && npm i'

maybe I should write my own dot files and not user others’ in future.

I was using,

https://github.com/addyosmani/dotfiles.git