node.js npm 安装错误 ENOTDIR
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13452791/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
npm install error ENOTDIR
提问by Siddharth
I am very new to Node.js and trying to install Flatiron using npm but it gives me an error.
我对 Node.js 非常陌生,并尝试使用 npm 安装 Flatiron,但它给了我一个错误。
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! <[email protected]>
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.
这里有什么问题?我没有线索。
回答by Daithí
Just solved the issue. Its because there's a file called tmpin the home directory.
刚刚解决了这个问题。这是因为tmp在主目录中有一个文件被调用。
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
另外...如果您尝试安装 npm 那么同样的错误和解决方案适用 - 删除 ~/tmp
回答by Tolga Akyüz
Try
尝试
sudo mkdir -p /home/siddharthsaha/tmp
sudo npm cache clear
before starting the install script, since npm http 304 https://registry.npmjs.org/flatironline states that this module is coming from cache. And also ENOTDIRstates that there is no directory. Therefore, emptying the cache would solve your problem.
在启动安装脚本之前,因为该npm http 304 https://registry.npmjs.org/flatiron行表明该模块来自缓存。并且还ENOTDIR指出没有目录。因此,清空缓存将解决您的问题。
回答by Scott Stensland
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.
以下是从没有 root 的源代码安装给定版本的步骤注意 - 这将安装 nodejs,它为您提供 node 和 npm,它们在每个版本中组合在一起。
to start fresh remove prior node.js and npm installs as well as these :
重新开始删除之前的 node.js 和 npm 安装以及这些:
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) :
以自己的身份安装 nodejs 和 npm,而不是 root 执行这些命令(OSX/linux):
export NODE_PARENT=${HOME}/bin_0_10_32
mkdir ${NODE_PARENT}
download source from : http://nodejs.org/download/
下载源: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
将它放入上面定义的目录中 --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 :
定义环境变量 NODE_PATH 以便节点可以找到模块的目录,否则 npm install xxx 会将新安装的模块放入当前目录:
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
当您使用语法时: npm install -g some_cool_module 全局的 -g 将其安装到目录 $NODE_PATH 而不是您的 $PWD
nodejs install gives you npm as well :
nodejs install 也给你 npm :
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
使用全局标志 -g 安装的后续模块将自动将它们的 ~binaries~ 放入 bin 目录上方......就像 browserify
Now put above three export xxx=yyy commands into your ~/.bashrc or some such so your environment is setup
现在将以上三个 export xxx=yyy 命令放入您的 ~/.bashrc 或类似命令中,这样您的环境就设置好了
回答by bnPYSse
I direct delete the file of npm-debug.log. then it's ok for me.
我直接删除npm-debug.log文件。那对我来说没问题。

