当前位置: 首页 > 工具软件 > iNotify.js > 使用案例 >

Node.js:什么是ENOSPC错误以及如何解决?

颛孙高义
2023-12-01

本文翻译自:Node.js: what is ENOSPC error and how to solve?

I have a problem with Node.js and uploading files to server. 我在使用Node.js并将文件上传到服务器时遇到问题。 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进程崩溃并显示错误:

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

#1楼

参考:https://stackoom.com/question/1WIzh/Node-js-什么是ENOSPC错误以及如何解决


#2楼

ENOSPC means that there is no space on the drive. ENOSPC表示驱动器上没有空间。

Perhaps /tmp is full? 也许/tmp已满? You can configure npm to use a different temp folder by setting npm config set tmp /path/to/some/other/dir , or maybe delete everything out of the /tmp folder. 您可以配置npm通过设置使用不同的临时文件夹npm config set tmp /path/to/some/other/dir ,也许删除所有出的/tmp文件夹中。

Source: npm 1.1.21 cannot write, ENOSPC in 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 answer below, which is more comprehensive. 但是,请参阅下面的Murali Krishna的答案 ,该答案更为全面。


#3楼

If your /tmp mount on a linux filesystem is mounted as overflow (often sized at 1MB), this is likely due to you not specifying /tmp as its own partition and your root filesystem filled up and /tmp was remounted as a fallback. 如果您在Linux文件系统上的/tmp挂载被安装为溢出(通常大小为1MB),则可能是由于您未将/tmp指定为其自己的分区,并且您的根文件系统已填满,并且/tmp被挂载为后备。

To fix this after you've cleared space, just unmount the fallback and it should remount at its original point: 要在清除空间后解决此问题,只需卸载后备,它应该在原始位置重新安装:

sudo umount overflow

#4楼

In my case, on linux, sudoing fixed the problem. 以我为例,在Linux上,sudoing解决了该问题。

Example: 例:

sudo gulp dev

#5楼

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 技术细节来源


#6楼

Can't take credit for this, but @grenade pointed out that npm dedupe will fix the cause (too many files) and not the symptom. 对此不敢恭维 ,但@grenade指出npm dedupe Dedupe将解决问题的原因(文件过多),而不是症状。

Source: Grunt watch error - Waiting…Fatal error: watch ENOSPC . 来源: Grunt观看错误-等待中…致命错误:观看ENOSPC

 类似资料: