简体   繁体   English

如何在虚拟机 5.0.2、CentOS 7 作为来宾、Windows 7 作为主机中创建符号链接

[英]How to create symlink in virtual box 5.0.2, CentOS 7 as guest, Windows 7 as host

I am trying to set up a CentOS 7 as my development box in Virtual Box 5.0.2.我正在尝试将 CentOS 7 设置为我在 Virtual Box 5.0.2 中的开发箱。 I share the project folder from the host, that is running windows 7, with the guest (then I can use the windows GUI and use an IDE to do the interaction on windows, while my code is running on CentOS).我与来宾共享来自运行 Windows 7 的主机的项目文件夹(然后我可以使用 Windows GUI 并使用 IDE 在 Windows 上进行交互,而我的代码在 CentOS 上运行)。

I am doing some development in node.我正在 node.js 中做一些开发。 While setting up my project and doing npm install , I got an error as:在设置我的项目并执行npm install ,我收到一个错误:

49132 error Linux 3.10.0-327.13.1.el7.x86_64
49133 error argv "/home/wdd/nvm/versions/node/v5.10.0/bin/node" "/home/wdd/nvm/versions/node/v5.10.0/bin/npm" "install"
49134 error node v5.10.0
49135 error npm  v3.8.3
49136 error path /home/wdd/share/mynps-corporate-client/node_modules/.staging/iconv-lite-94545a9f
49137 error code EPERM
49138 error errno -1
49139 error syscall rename
49140 error Error: EPERM: operation not permitted, rename '/home/wdd/share/mynps-corporate-client/node_modules/.staging/iconv-lite-94545a9f' -> '/home/wdd/share/mynps-corporate-client/node_modules/iconv-lite'
49140 error     at destStatted (/home/wdd/nvm/versions/node/v5.10.0/lib/node_modules/npm/lib/install/action/finalize.js:25:7)
49140 error     at FSReqWrap.oncomplete (fs.js:82:15)
49140 error
49140 error Error: EPERM: operation not permitted, rename '/home/wdd/share/mynps-corporate-client/node_modules/.staging/iconv-lite-94545a9f' -> '/home/wdd/share/mynps-corporate-client/node_modules/iconv-lite'
49140 error     at Error (native)
49140 error  { [Error: EPERM: operation not permitted, rename '/home/wdd/share/mynps-corporate-client/node_modules/.staging/iconv-lite-94545a9f' -> '/home/wdd/share/mynps-corporate-client/node_modules/iconv-lite'] parent: 'mynps-corporate' }
49141 error Please try running this command again as root/Administrator.
49142 verbose exit [ -1, true ]

When I searched online, I get to know the problem is with the symlinks.当我在网上搜索时,我知道问题出在符号链接上。 Symlinks are disabled by default on shared folders, so the following also fails:默认情况下,共享文件夹上的符号链接是禁用的,因此以下操作也会失败:

ln: failed to create hard link ‘ln-server.js’ => ‘server.js’: Operation not permitted

I have tried:我试过:

  • sudo on guest sudo来宾
  • 'Run as Administrator' virtual box on host.主机上的“以管理员身份运行”虚拟框。
  • VBoxManage setextradata VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/SHARE_NAME 1
  • Updated User Security Policy and allowed create symbolic links to 'Everyone'更新了用户安全策略并允许创建指向“所有人”的符号链接
  • Allowed all the privileges to everyone on security settings of the project folder properties in host machine.允许所有人对主机中项目文件夹属性的安全设置具有所有权限。

I have already used the following links:我已经使用了以下链接:

Update (2016-04-21): For now I have made a work around.更新(2016-04-21):现在我已经解决了。 I do an npm install in a directory that is not shared, and then moved the node_modules directory to the shared directory, and there is no problem.我在一个没有共享的目录下做npm install ,然后把node_modules目录移到了共享目录下,没有问题。 As it we do not install modules so frequently, it is fine.因为我们不那么频繁地安装模块,所以没问题。 But yet, it would be great if one can point out a real solution for this.但是,如果有人能为此指出一个真正的解决方案,那就太好了。

The easiest way to deal with node_modules issues in a VM from a shared Windows project folder is to bind mount node_modules from another location in the Linux filesystem, but be sure to mount it after the virtualbox shared filesystem is mounted.从共享 Windows 项目文件夹处理 VM 中 node_modules 问题的最简单方法是从 Linux 文件系统中的另一个位置绑定挂载 node_modules,但一定要在挂载 virtualbox 共享文件系统挂载它。

mkdir -p /home/wdd/node_modules /home/wdd/share/mynps-corporate-client/node_modules

sudo mount --bind /home/wdd/node_modules /home/wdd/share/mynps-corporate-client/node_modules

You will not see the contents of node_modules outside of the VM, but you will not have any more issues with symbolic links or path lengths.您不会在 VM 之外看到 node_modules 的内容,但您不会再遇到符号链接或路径长度方面的问题。

Accepted solution did not work for me.接受的解决方案对我不起作用。 I ended up running npm install on Windows rather than Linux.我最终在 Windows 而不是 Linux 上运行 npm install 。 This might be a problem for certain packages however.然而,这对于某些软件包来说可能是一个问题。

I have found one more solution that I haven't tried yet.我找到了另一种尚未尝试过的解决方案。 You could maybe skip creating symlinks if it's only problem with them.如果只是符号链接有问题,您可以跳过创建符号链接。

npm install --no-bin-links

See more here:在此处查看更多信息:

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM