0

I get the following error when trying to use npm on mac. I'm on mac 10.10.1

$ npm
Error: ENAMETOOLONG, mkdir '/Users/LM/npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   '-g',
npm verb cli   'config',
npm verb cli   'get',
npm verb cli   'prefix' ]
npm info using npm@2.1.6
npm info using node@v0.10.33
npm verb node symlink /usr/local/bin/node
/Users/LM/Desktop/Titanium Studio/TitaniumStudio.app/Contents/MacOS/npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   '-g',
npm verb cli   'config',
npm verb cli   'get',
npm verb cli   'prefix' ]
npm info using npm@2.1.6
npm info using node@v0.10.33
npm verb node symlink /usr/local/bin/node
/Users/LM/Desktop/Titanium Studio/TitaniumStudio.app/Contents/MacOS/npm info it worked if it ends with ok
npm verb cli [ '/usr/local/bin/node',
npm verb cli   '/usr/local/bin/npm',
npm verb cli   '-g',
npm verb cli   'config',
npm verb cli   'get',
npm verb cli   'prefix' ]
npm info using npm@2.1.6
npm info using node@v0.10.33
npm verb node symlink /usr/local/bin/node
/usr/local
npm verb exit [ 0, true ]
npm info ok
npm verb exit [ 0, true ]
npm info ok
npm verb exit [ 0, true ]
npm info ok'

Any ideas what this means and how to fix?

King Julien
  • 10,981
  • 24
  • 94
  • 132

4 Answers4

0

I think the issue is due to the permissions. Try to change the permissions as followed :

  1. Unlock permissions in your home directory.

    sudo chown -R `whoami` ~/.npm
    
  2. If 1 does not work, get write permissions to the node_modules directory.

    sudo chown -R `whoami` /usr/local/lib/node_modules
    
  3. If you still face error, update permission of /usr/local.

    sudo chown -R `whoami` /usr/local
    

Hope it helps.

turtle
  • 1,619
  • 1
  • 14
  • 30
  • There is no `.npm` in ~. Run other commands but same problem. – King Julien Nov 25 '14 at 11:14
  • if you still face the error, try to uninstall all node and npm instances and install fresh via [brew](http://thechangelog.com/install-node-js-with-homebrew-on-os-x/) or via [curl](http://stackoverflow.com/a/9377023/3419997). – turtle Nov 25 '14 at 11:40
  • what is the version of node and npm you have ? – turtle Nov 25 '14 at 12:23
  • As it is shown from the log npm version is 2.1.6 and node version os 0.10.33 – King Julien Nov 25 '14 at 12:43
0

The error ENAMETOOLONG means that nodejs (or the OS) is trying to use a pathname component that exceeds your OS's maximum (in the case of OSX, 31).

Firstly where have you tried to install nodejs from? This could be the cause of your issue. I've never used Titanium Studio but your question reads like this is the intall of nodejs that you are using.

You may be best installing node directly from github. The following should get you started.

Install Node

mkdir ~/src
cd ~/src
git clone https://github.com/joyent/node.git
cd node
git checkout v0.10.33
mkdir ~/local

./configure --prefix=$HOME/local/node
make
make install

Dont forget to add $HOME/local/node/bin to your PATH enviromental variable. You can test your node installation by

node -v

Install NPM

curl http://npmjs.org/install.sh | sh

You can test your npm installation by

npm -v
Kinetic
  • 1,714
  • 1
  • 13
  • 38
0

There are several solutions suggested here, where somebody has the exact same problem, also using titanium studio: https://developer.appcelerator.com/question/179230/unable-to-properly-update-titanium-studio

  • Manually updating CLI, Node.ACS, and Alloy

    sudo npm install -g alloy@1.5.1
    sudo npm install -g titanium@3.4.1
    sudo npm install -g acs

  • Change permissions to the directory

    sudo chown -R whoami ~/.npm

Although it seems that the last thing did not work. You might want to have a look here as well: NPM throws error without sudo

Schnodderbalken
  • 3,257
  • 4
  • 34
  • 60
  • If you are using -g you are installing into the system path, not in the homedir folder of `whoami`. – Marcs Dec 01 '14 at 22:23
0

1. Discover where npm executables exist

First, find out where npm executables exist on your system:

$ which -a npm

This should output two or more system paths.

2. Find out your shell's $PATH

Then, determine the search paths for your command execution:

$ echo $PATH

This will give you a colon-separated list of directories your session is searching for executables like npm.

3. Give priority to a different npm

Appcelerator Titanium has corrupted one or more aspects of your system. You may want to temporarily uninstall Titanium.

Otherwise, to give preference to another Node.js installation, you can edit your $PATH or even more simply, create a shell alias. For example:

$ alias npm=/usr/local/bin/npm

In most cases, you can "save" this in your ~/.bash_profile file (by simply copying and pasting the text as if you were at the prompt) so that it's applied to future shell sessions.

Jacob Budin
  • 9,753
  • 4
  • 32
  • 35