NPM无法在Windows 10主机上的Ubuntu下的Virtualbox共享文件夹上工作

1wnzp6jl  于 8个月前  发布在  Windows
关注(0)|答案(1)|浏览(93)

我正在尝试使用Vagrant在Virtualbox机器上设置开发环境。我使用Windows 10作为主机,ubuntu/bionic 64作为客户机。
我的package.json文件位于主机和客户机之间的共享目录下。然而,每当我运行npm install --no-bin-links时,我都会得到以下错误:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/vagrant/www/wp-content/plugins/my-plugin/node_modules/array-initial/node_modules/is-number/package.json.1640612897
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/vagrant/www/wp-content/plugins/my-plugin/node_modules/array-initial/node_modules/is-number
/package.json.1640612897'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2021-01-19T05_31_47_272Z-debug.log

字符串
在客户机内部,如果我将package.jsonpackage-lock.json复制到另一个不共享的目录中,然后运行npm install,一切都可以正常工作。

mkdir /tmp/test/
cp package.json package-lock.json /tmp/test/
cd /tmp/test/ && npm install 
# NPM Packages are installed successfully!


我认为这个错误是Windows特有的,因为我已经使用Ubuntu很多年了,从来没有遇到过类似的问题。我一周前才开始使用Windows。
奇怪的是,我在同一台机器上还有另一个开发环境,NPM工作得很好,没有任何共享文件夹的问题!
我使用的是--no-bin-links,所以我不认为这个问题与符号链接有任何关系。
查看strace输出,我无法看到此文件node_modules/array-initial/node_modules/is-number /package.json.1640612897是何时创建的。
NPM log
Strace log

w80xi6nr

w80xi6nr1#

您需要启用符号链接:

VBoxManage setextradata YOUR_VM_NAME VBoxInternal2/SharedFoldersEnableSymlinksCreate/YOUR_SHARED_FOLDER_NAME 1

字符串
然后重新启动VM。
如需详细信息,请参阅https://www.virtualbox.org/ticket/10085#comment:12。

相关问题