我试图在Virtualbox虚拟机上使用Vagrant建立开发环境。我的主机操作系统是Windows 10,客户机操作系统是ubuntu/bionic64。
我的
在客户机(虚拟机)内部,如果我将
我的
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.json
和 package-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
的时间。