【发布时间】:2018-10-15 12:31:54
【问题描述】:
用两天时间处理这个问题,结果成功了。
我有一个全新安装的Windows 10 主机,运行最新版本的Vagrant、laravel/homestead (Ubuntu 18.04 LTS box, v 6.0.0)、Virtualbox、laravel、git for windows、node.js for windows。
vagrant、git、virtualbox 设置为在windows 中以管理员身份运行。
我创建了一个名为 blog 的 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
结果是node_modules 中的highchatrts 文件夹,其中只有packaje.json.1984492036 文件。
我似乎找不到解决办法。使用 --no-bin-links 会出现同样的错误。
感谢任何帮助。
【问题讨论】:
-
嗨@Mohdule 完全相同的结果。谢谢
-
stackoverflow.com/a/49122289/470749 说 not 运行
sudo并链接到描述如何处理此问题的官方文档。