我正在使用nvm来管理npm,这是在vagrant ubuntubionic64容器内进行的。这是在一个vagrant ubuntubionic64容器中进行的。
我的全局node_modules在 /home/vagrant
而我的项目是在 /vagrant
,默认同步的vagrant文件夹。
当我做 vue create myproject
我明白了。
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /vagrant/project/myproject/node_modules/@soda/friendly-errors-webpack-plugin/node_modules/string-width/node_modules/ansi-regex/package.json.2916702147
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/vagrant/project/myproject/node_modules/@soda/friendly-errors-webpack-plugin/node_modules/string-width/node_modules/ansi-regex/package.json.2916702147'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent
但是... ansi-regex
可以发现全球在。/home/vagrant/.nvm/versions/node/v14.2.0/bin
当我做 vue create myproject
在 /home/vagrant
它工作了! 但我想把我的项目放在默认的共享vagrant文件夹中。/vagrant
有什么办法吗?
Vagrant不支持同步文件夹的符号链接。将此添加到您的Vagrant文件中。
config.vm.provider "virtualbox" do |v|
# Enable symlinks in vagrant shared folder, https://coderwall.com/p/b5mu2w
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/v-root", "1"]
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant-root", "1"]
v.customize ["setextradata", :id, "VBoxInternal2/SharedFoldersEnableSymlinksCreate/vagrant", "1"]
end