1

Not sure what happened but my Node + NPM are just mucked up completely. I've tried uninstalling everything node/npm related - reinstalling using NVM. Install works great -

➜  ~ npm -v
5.3.0
➜  ~ node -v
v8.2.1

But I keep getting errors absolutely everywhere - no matter what project/package I'm in.

For example - I'm trying to install Hexo (static site generator) with this command -

npm install hexo-cli -g

Install works fine, but the 'hexo' command gives me -

➜  ~ hexo
zsh: command not found: hexo

Alright, this isn't terrible - let's try another project. Here I cloned the following Node project https://github.com/EmailThis/extension-boilerplate into a folder called 'learnio'

npm install works okay -

➜  learnio git:(master) ✗ npm install
npm WARN extension-boilerplate@0.0.2 No license field.

up to date in 4.289s

But npm run build gives me -

➜  learnio git:(master) ✗ npm run build

> extension-boilerplate@0.0.2 build /home/patrick/Programming/learnio
> cross-env NODE_ENV=production npm run chrome-build && cross-env NODE_ENV=production npm run opera-build && cross-env NODE_ENV=production npm run firefox-build

sh: 1: cross-env: not found
npm ERR! file sh
npm ERR! code ELIFECYCLE
npm ERR! errno ENOENT
npm ERR! syscall spawn
npm ERR! extension-boilerplate@0.0.2 build: `cross-env NODE_ENV=production npm run chrome-build && cross-env NODE_ENV=production npm run opera-build && cross-env NODE_ENV=production npm run firefox-build`
npm ERR! spawn ENOENT
npm ERR! 
npm ERR! Failed at the extension-boilerplate@0.0.2 build 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!     /home/patrick/.npm/_logs/2017-07-31T03_59_53_074Z-debug.log

I've tried to install cross-env manually, but no go.

These are just a few of the problems I'm having. Is this a permissions issue? I've tried chowning as many npm/node folders as possible, nothing is working.

Usually in this case I'd just reinstall my OS (Debian) but I'm travelling at the moment and don't have the time luxury to do that sadly.

Any help would be appreciated, thanks so much.

Ry-
  • 218,210
  • 55
  • 464
  • 476
Pat
  • 225
  • 3
  • 11
  • have you add npm global bin directory to your PATH? Alternatively since you're using `npm` 5.3.0 ; you can try `npx hexo` :) – Tuan Anh Tran Jul 31 '17 at 04:08
  • @TuanAnhTran hmm, trying to add it. My global bin directory is coming up with a few different results though, what's the ideal command to find that directory? Thanks. – Pat Jul 31 '17 at 04:46
  • You can ccheck where npm global dir is by `npm list -g` ? – Tuan Anh Tran Jul 31 '17 at 06:32
  • @TuanAnhTran so that's giving me this path - /home/patrick/.nvm/versions/node/v8.2.1/lib/node_modules I added that to my .zshrc like this: export PATH=$HOME/bin:/usr/local/bin/:$HOME/node_modules/:$HOME/.nvm/:$HOME/.nvm/versions/node/v8.2.1/lib/:$HOME/node_modules/.bin/:/home/patrick/.nvm/versions/node/v8.2.1/lib/node_modules/:$PATH But still no go. – Pat Jul 31 '17 at 06:36
  • i think you have to add bin folder of that instead. – Tuan Anh Tran Jul 31 '17 at 07:23
  • @TuanAnhTran it recognizes the global modules now but now I get "permission denied" when I try and run 'nodemon' for example. – Pat Aug 01 '17 at 04:40
  • Usually, i change npm global folder to a folder inside user home https://stackoverflow.com/questions/6685892/how-do-i-fix-npms-global-location – Tuan Anh Tran Aug 01 '17 at 04:41
  • Let us [continue this discussion in chat](http://chat.stackoverflow.com/rooms/150677/discussion-between-bolle-and-tuan-anh-tran). – Pat Aug 01 '17 at 04:43

0 Answers0