18

I am very new to Node.js and trying to install Flatiron using npm but it gives me an error.

sudo npm install flatiron -g

And I get -

npm http GET https://registry.npmjs.org/flatiron
npm http 304 https://registry.npmjs.org/flatiron
npm ERR! Error: ENOTDIR, mkdir '/home/siddharthsaha/tmp/npm-28554/1353323290836-0.20847953506745398'
npm ERR! If you need help, you may report this log at:
npm ERR!     <http://github.com/isaacs/npm/issues>
npm ERR! or email it to:
npm ERR!     <npm-@googlegroups.com>

npm ERR! System Linux 3.2.0-24-generic
npm ERR! command "/usr/local/bin/node" "/usr/local/bin/npm" "install" "flatiron" "-g"
npm ERR! cwd /home/siddharthsaha/denarit
npm ERR! node -v v0.8.14
npm ERR! npm -v 1.1.65
npm ERR! path /home/siddharthsaha/tmp/npm-28554/1353323290836-0.20847953506745398
npm ERR! code ENOTDIR
npm ERR! errno 27
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/siddharthsaha/denarit/npm-debug.log
npm ERR! not ok code 0

What is wrong here? I have no clue.

Siddharth
  • 5,009
  • 11
  • 49
  • 71

4 Answers4

24

Just solved the issue. Its because there's a file called tmp in the home directory.

rm -rf ~/tmp
sudo npm cache clear
sudo npm install -g node

Also... if you are trying to install npm then the same error and solution applies - delete ~/tmp

Daithí
  • 4,717
  • 5
  • 26
  • 35
21

Try

sudo mkdir -p /home/siddharthsaha/tmp
sudo npm cache clear

before starting the install script, since npm http 304 https://registry.npmjs.org/flatiron line states that this module is coming from cache. And also ENOTDIR states that there is no directory. Therefore, emptying the cache would solve your problem.

tolgaio
  • 3,206
  • 1
  • 19
  • 18
  • Nope I get the same error except the 304 now changes to 200 and so it is not coming from cache anymore. – Siddharth Nov 19 '12 at 12:32
  • Can you try to install it wihout `-g`, mean locally. Let us see how it will go. – tolgaio Nov 19 '12 at 13:05
  • No luck still. I did `sudo npm cache clean` and then did `sudo npm install flatiron` and I get the same error. – Siddharth Nov 19 '12 at 13:15
  • can you try `sudo rm -rf /home/siddharthsaha/tmp`? – tolgaio Nov 19 '12 at 13:24
  • and also which version of node you are using. re-isntalling latest node version may solve your problem (as in most cases) – tolgaio Nov 19 '12 at 13:26
  • The strange thing is `/home/siddharthsaha/tmp` does not even exists. I am not sure why is it using that directory. Yes, I have the latest node version - I installed the latest one before starting today, that is, 0.8.14. – Siddharth Nov 19 '12 at 15:52
  • 1
    Ok then try creating that directory `sudo mkdir -p /home/siddharthsaha/tmp`, clear the cache and install, this is the final thing i came up. – tolgaio Nov 19 '12 at 15:56
  • I created the `/home/siddharthsaha/tmp` directory and ran install again. It failed, then I removed the tmp directory and ran install again and it worked. – Siddharth Nov 19 '12 at 15:56
  • 4
    In my case, there was a file named "tmp" in my home dir, so I simply had to rename this tmp file so npm could create tmp as a dir. – therealklanni Aug 23 '13 at 04:04
0

Below are the steps to install a given release from source without root NOTE - this installs nodejs which gives you both node as well as npm, they come together per release.

to start fresh remove prior node.js and npm installs as well as these :

sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm   ~/.npm_ignore
sudo mv ~/tmp    ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore

to install nodejs and npm as yourself NOT root do these commands (OSX/linux) :

export NODE_PARENT=${HOME}/bin_0_10_32

mkdir ${NODE_PARENT}

download source from : http://nodejs.org/download/

cd node-v0.xxxx

./configure   --prefix=${NODE_PARENT}/nodejs

make -j8
make install   #  IMPORTANT this is NOT using sudo
               # not wanted since installing into $USER owned $NODE_PARENT

which puts it into dir defined by above --prefix

export PATH=${NODE_PARENT}/nodejs/bin:$PATH

define environment variable NODE_PATH so node can find dir for modules otherwise npm install xxx will put newly installed module into current dir :

export NODE_PATH=${NODE_PARENT}/nodejs/lib/node_modules

when you use syntax : npm install -g some_cool_module the -g for global installs it into dir $NODE_PATH and not your $PWD

nodejs install gives you npm as well :

ls -la ${NODE_PARENT}/nodejs/bin

Subsequent modules you install using global flag -g will automagically put their ~binaries~ into above bin dir ... like browserify

Now put above three export xxx=yyy commands into your ~/.bashrc or some such so your environment is setup

Scott Stensland
  • 26,870
  • 12
  • 93
  • 104
0

I direct delete the file of npm-debug.log. then it's ok for me.

bnPYSse
  • 397
  • 4
  • 12