node.js “EXDEV:不允许跨设备链接”错误是什么意思?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/43206198/
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

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 18:08:49  来源:igfitidea点击:

What does the "EXDEV: cross-device link not permitted" error mean?

node.jslibuv

提问by callum

What does this error actually mean? What is a "cross-device link"?

这个错误实际上意味着什么?什么是“跨设备链接”?

It is mentioned on this libuv pagebut it doesn't give any details beyond "cross-device link not permitted".

这个 libuv 页面上提到了它,但除了“不允许跨设备链接”之外,它没有提供任何详细信息。

采纳答案by rsp

It is used for EXDEV on Linux:

它用于 Linux 上的 EXDEV:

See man renamemanpage:

请参阅man rename联机帮助页:

EXDEV oldpath and newpath are not on the same mounted filesystem. (Linux permits a filesystem to be mounted at multiple points, but rename() does not work across different mount points, even if the same filesystem is mounted on both.)

EXDEV oldpath 和 newpath 不在同一个挂载的文件系统上。(Linux 允许在多个点挂载文件系统,但 rename() 不能跨不同的挂载点工作,即使在两个挂载点上都挂载了相同的文件系统。)

This error is also used when there is ERROR_NOT_SAME_DEVICEon Windows, see:

ERROR_NOT_SAME_DEVICE在 Windows 上也有这个错误,见:

For more info see:

有关更多信息,请参阅:

winerror.h 0x80070011 #define ERROR_NOT_SAME_DEVICEThe system cannot move the file to a different disk drive.

winerror.h 0x80070011 #define ERROR_NOT_SAME_DEVICE系统无法将文件移动到不同的磁盘驱动器。

回答by robertklep

It sounds like you're trying to rename a file across "device" (partition) boundaries.

听起来您正在尝试跨“设备”(分区)边界重命名文件。

Say that /tmpis a different partition than /. That means that you're not allowed to do this:

假设这/tmp是一个不同的分区/。这意味着你不能这样做:

fs.rename('/tmp/myfile.txt', '/myfile.txt', ...)

(the same applies to fs.renameSync()as well, obviously)

fs.renameSync()显然,这同样适用于)

If you want to do that, you need to first copythe file to its new location, and subsequently remove the old file. There are modules, like mv, that can help you with that.

如果要这样做,您需要先将文件复制到新位置,然后删除旧文件。有一些模块,例如mv,可以帮助您解决这个问题。

回答by Suleman Hasib

Just for they guys who are using Linux this happens when your old path i.e. /tmpand new path are on different partitions or disks.

仅对于使用 Linux 的人来说,当您的旧路径(即/tmp新路径)位于不同的分区或磁盘上时,就会发生这种情况。