2

When I start a new tmux sessions with tmux, tmux new or tmux new-session, I get the following error:

module.js:549
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run `npm config delete prefix` or `nvm use --delete-prefix v10.8.0 --silent` to unset it.

I have tried the solution for this question i.e. npm delete prefix but to no avail: running outside the tmux session doesn't fix the problem, and running within the tmux session throws the top section of the previous error again (without the npm warning):

module.js:549
    throw err;
    ^

Error: Cannot find module '../lib/utils/unsupported.js'
    at Function.Module._resolveFilename (module.js:547:15)
    at Function.Module._load (module.js:474:25)
    at Module.require (module.js:596:17)
    at require (internal/module.js:11:18)
    at /usr/local/lib/node_modules/npm/bin/npm-cli.js:19:21
    at Object.<anonymous> (/usr/local/lib/node_modules/npm/bin/npm-cli.js:153:3)
    at Module._compile (module.js:652:30)
    at Object.Module._extensions..js (module.js:663:10)
    at Module.load (module.js:565:32)
    at tryModuleLoad (module.js:505:12)

This appears to be an issue with npm somehow as the .js error also occurs when I run npm --help. However, this only occurs within tmux.

Any solutions?

James Mulholland
  • 1,782
  • 1
  • 14
  • 21
  • I have also discovered this problem only on MacOS. Works fine on Linux. Also npm and node work fine for me even on MacOS (I don't get the JS error you do), but as soon as the shell starts I get the `nvm is not compatible with...` message. It's also running a system version of node, and I can use a different version with nvm. But curious why this only happens with tmux – Jeff Puckett Jun 19 '19 at 21:13

5 Answers5

1

I think that you should run

npm install

this should do the trick.

UserX
  • 105
  • 1
  • 10
  • Sorry that doesn't work for me. This appears as soon as the shell starts. Were you able to reproduce the error with `nvm`? – Jeff Puckett Jun 20 '19 at 18:44
1

After digging on the internet I found some accepted answers:

Try config the $NVM_DIR reference again.

For example nvm use v7.10.0, and have the error: Run npm config delete prefix or nvm use --delete-prefix v7.10.0 --silent to unset it.

You need overwrite nvm prefix,

npm config set prefix $NVM_DIR/versions/node/v7.10.0

https://github.com/nvm-sh/nvm/issues/855#issuecomment-314309706

OR

If you're using any other shell than bash, make sure to configure your tmux that way:

# set default shell to zsh
set -g default-command /bin/zsh
set -g default-shell /bin/zsh

This solved it for me.

https://github.com/nvm-sh/nvm/issues/1245#issuecomment-370396741

OR

comment out the code below in your shell file (such as ~/.zshrc):

export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh"  # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion"  # This loads nvm bash_completion

log out your account and log in

uncommnet these code above and source shell file

OR

nvm unalias default

https://stackoverflow.com/a/47861348/6700273 https://blog.natetodd.com/nvm/

Rohit Dhiman
  • 2,691
  • 18
  • 33
0

Fixed: it looks like this might be specific to how macOS handles pathes on each bash shell. Adding the recommended path-clearing logic to my profile files fixed this issue for me.

Seeing this too, just on tmux, with nvm installed via the curl script.

Oddly, it seems like I'm using different versions of npm when in tmux and when I'm just in my shell (zsh). When I'm in tmux, doing a which npm results in /usr/local/bin/npm while in zsh, it's /Users/brett/.nvm/versions/node/v10.8.0/bin/npm.

It seems like it might be related to tmux reloading my profile files, and appending more paths to $PATH.

Look here: When using tmux nvm isn't being sourced

Umbro
  • 1,984
  • 12
  • 40
  • 99
0

Bash starts as a login shell in tmux. On macOS it is ~/.bash_profile, not ~/.bashrc that is sourced then, AFAIK.

Have you tried adding source ~/.bashrc to your ~/.bash_profile?

Mateusz Piotrowski
  • 8,029
  • 10
  • 53
  • 79
0

Here is another possible solution:

$ npm config delete prefix 
$ npm config set prefix $NVM_DIR/versions/node/v6.11.1

This should delete and reset the prefix, which you can edit later.

UserX
  • 105
  • 1
  • 10