关于全新安装Homestead / Vagrant / Laravel的npm许可问题

时间:2018-05-05 01:07:50

标签: laravel npm vagrant

处理这个问题两天就赢了。

我全新安装Windows 10主机,运行最新版本的Vagrantlaravel/homestead (Ubuntu 18.04 LTS box, v 6.0.0)Virtualboxlaravelgit for windowsnode.js for windows

vagrantgitvirtualbox设置为在windows中以管理员身份运行。

我创建一个名为博客的Laravel项目,如下所示:

vagrant@homestead:~/src$ composer create-project --prefer-dist laravel/laravel blog

全部创建好。然后我尝试像这样安装npm

vagrant@homestead:~/src/blog$ npm install -g npm@latest

我得到了:

npm WARN checkPermissions Missing write access to /usr/lib/node_modules/npm
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! path /usr/lib/node_modules/npm
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules/npm'
npm ERR!  { Error: EACCES: permission denied, access '/usr/lib/node_modules/npm'
npm ERR!   stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules/npm\'',
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'access',
npm ERR!   path: '/usr/lib/node_modules/npm' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-05-05T00_57_41_110Z-debug.log

但是当我检查vagrant用户权限时:

vagrant@homestead:~/src/blog$ groups
vagrant adm cdrom sudo dip www-data plugdev lxd lpadmin sambashare

所以我用npm消息不推荐解决这个问题:

vagrant@homestead:~/src/blog$ sudo npm install -g npm@latest

我现在去安装一个npm包,例如highcharts

vagrant@homestead:~/src/blog$ npm install --save highcharts
npm WARN rollback Rolling back highcharts@6.1.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515'
npm ERR! path /home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/src/blog/node_modules/highcharts/package.json.2262439515' -> '/home/vagrant/src/blog/node_modules/highcharts/package.json'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-05-05T01_10_24_241Z-debug.log

我尝试sudo安装包,结果相同

vagrant@homestead:~/src/blog$ sudo npm install --save --no-bin-links highcharts 
npm WARN rollback Rolling back highcharts@6.1.0 failed (this is probably harmless): ETXTBSY: text file is busy, unlink '/home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036'
npm ERR! path /home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036
npm ERR! code ETXTBSY
npm ERR! errno -26
npm ERR! syscall rename
npm ERR! ETXTBSY: text file is busy, rename '/home/vagrant/src/blog/node_modules/highcharts/package.json.1984492036' -> '/home/vagrant/src/blog/node_modules/highcharts/package.json'

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/vagrant/.npm/_logs/2018-05-05T01_58_13_140Z-debug.log

结果是highchatrts中的node_modules文件夹,其中只包含packaje.json.1984492036个文件。

我似乎无法找到解决方法。使用--no-bin-links会出现同样的错误。

感谢任何帮助。

2 个答案:

答案 0 :(得分:0)

两天前我遇到同样的问题,尝试运行sudo npm install --unsafe-perm,撤消您先做的任何更改,因为我不知道代客是如何工作的(悲伤的Linux用户)

答案 1 :(得分:0)

我通过从fit主机操作系统运行npm install而不是从git vm运行来完成所有工作。不是我想要的,但我向前迈进,学会了一些东西,并且更接近疯狂......

相关问题