Node.js:什么是 ENOSPC 错误以及如何解决?
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/22475849/
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
Node.js: what is ENOSPC error and how to solve?
提问by Giffo
I have a problem with Node.js and uploading files to server. For uploading files to server I use this plugin. When starting file upload to the server, Node.js process crashed and show error:
我在使用 Node.js 并将文件上传到服务器时遇到问题。为了将文件上传到服务器,我使用了这个插件。启动文件上传到服务器时,Node.js 进程崩溃并显示错误:
Error: ENOSPC.
错误:ENOSPC。
The server code doesn't run.
服务器代码不运行。
$ df -h
Filesystem Size Used Avail Use% Mounted on
/dev/xvda1 7.9G 4.1G 3.5G 55% /
udev 288M 8.0K 288M 1% /dev
tmpfs 119M 168K 118M 1% /run
none 5.0M 0 5.0M 0% /run/lock
none 296M 0 296M 0% /run/shm
/dev/xvdf 9.9G 3.0G 6.5G 32% /vol
overflow 1.0M 1.0M 0 100% /tmp
回答by Murali Krishna
Run the below command to avoid ENOSPC:
运行以下命令以避免 ENOSPC:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
For Arch Linux add this line to /etc/sysctl.d/99-sysctl.conf:
对于 Arch Linux,将此行添加到/etc/sysctl.d/99-sysctl.conf:
fs.inotify.max_user_watches=524288
Then execute:
然后执行:
sysctl --system
This will also persist across reboots. Technical Details Source
这也将在重新启动后持续存在。 技术细节来源
回答by Blu
ENOSPCmeans that there is no space on the drive.
ENOSPC意味着驱动器上没有空间。
Perhaps /tmpis full? You can configure npmto use a different temp folder by setting npm config set tmp /path/to/some/other/dir, or maybe delete everything out of the /tmpfolder.
也许/tmp是满了?您可以npm通过设置来配置使用不同的临时文件夹npm config set tmp /path/to/some/other/dir,或者删除/tmp文件夹中的所有内容。
Source: npm 1.1.21 cannot write, ENOSPCin npm's repo in github.
来源:npm 1.1.21 不能写,在 github 中 npm 的 repo 中的ENOSPC。
Note I solved my problem in the way that described in above source. However, see Murali Krishna's answerbelow, which is more comprehensive.
注意我以上述来源中描述的方式解决了我的问题。但是,请参阅下面的Murali Krishna 的回答,它更全面。
回答by orbiteleven
Can't take credit for this, but @grenadepointed out that npm dedupewill fix the cause (too many files) and not the symptom.
不能因此而受到赞扬,但@grenade指出这npm dedupe将解决原因(文件过多)而不是症状。
Source: Grunt watch error - Waiting…Fatal error: watch ENOSPC.
回答by Danrley Willyan
A simple way that solve my problem was:
解决我的问题的一个简单方法是:
npm cache clear
npmor a process controlled by it is watching too many files. Updating max_user_watches on the build node can fix it forever. For debian put the following on terminal:
npm或由它控制的进程正在监视太多文件。在构建节点上更新 max_user_watches 可以永远修复它。对于 debian,在终端上输入以下内容:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf && sudo sysctl -p
If you want know how Increase the amount of inotify watchersonly click on link.
如果您想知道如何增加 inotify 观察者的数量,只需单击链接。
回答by Bjorn Reppen
Rebooting the machine solved the problem for me. I first tried wiping /tmp/but node was still complaining.
重新启动机器为我解决了问题。我首先尝试擦拭,/tmp/但节点仍在抱怨。
回答by Woodrow Barlow
On Linux, this is likely to be a limit on the number of file watches.
在 Linux 上,这可能是文件监视数量的限制。
The development server uses inotifyto implement hot-reloading. The inotify API allows the development server to watch files and be notified when they change.
开发服务器使用inotify来实现热重载。inotify API 允许开发服务器监视文件并在文件更改时收到通知。
The default inotify file watch limit varies from distribution to distribution (8192 on Fedora). The needs of the development server often exceeds this limit.
默认的 inotify 文件监视限制因发行版而异(Fedora 上为 8192)。开发服务器的需求往往超过这个限制。
The best approach is to try increasing the file watch limit temporarily, then making that a permanent configuration change if you're happy with it. Note, though, that this changes your entire system's configuration, not just node.
最好的方法是尝试暂时增加文件监视限制,如果您对此感到满意,则将其永久更改。但是请注意,这会更改整个系统的配置,而不仅仅是节点。
To view your current limit:
要查看您的当前限制:
sysctl fs.inotify.max_user_watches
To temporarily set a new limit:
临时设置新限制:
# this limit will revert after reset
sudo sysctl fs.inotify.max_user_watches=524288
sudo sysctl -p
# now restart the server and see if it works
To set a permanent limit:
要设置永久限制:
echo fs.inotify.max_user_watches=524288 | sudo tee -a /etc/sysctl.conf
sudo sysctl -p
回答by Daniel Kmak
If you encounter this error during trying to run ember servercommand please rm -rf tmpdirectory. Then run ember sagain. It helped me.
如果在尝试运行ember server命令期间遇到此错误,请rm -rf tmp目录。然后ember s再次运行。它帮助了我。
回答by Ghayyas Mubashir
I was having Same error. While I run Reactjs app. What I do is just remove the node_modules folder and type and install node_modules again. This remove the error.
我有同样的错误。当我运行 Reactjs 应用程序时。我所做的只是删除 node_modules 文件夹并再次键入并安装 node_modules。这消除了错误。
回答by Manolo de la Vega
On Ubuntu 18.04 , I tried a trick that I used to reactivate the file watching by ionic/node, and it works also here. This could be useful for those who don't have access to system conf files.
在 Ubuntu 18.04 上,我尝试了一个技巧,我用来重新激活 ionic/node 监视的文件,它也可以在这里工作。这对于那些无权访问系统 conf 文件的人可能很有用。
CHOKIDAR_USEPOLLING=1 npm start
回答by Denys Vitali
I solved my problem killing all tracker-control processes (you could try if you use GDM, obviously not your case if the script is running on a server)
我解决了杀死所有跟踪器控制进程的问题(如果您使用 GDM,您可以尝试,如果脚本在服务器上运行,显然不是您的情况)
tracker-control -r
My setup: Arch with GNOME 3
我的设置:Arch 与 GNOME 3

