npm install 报错 :npm ERR! ETXTBSY: text file is busy, rename ...

作者:admin 发布:2018-09-22 浏览:2982次

使用 vagrant 在 xshell 中执行 npm install 命令报错:

错误一:

npm ERR! path /vagrant/laravel/node_modules/laravel-mix/node_modules/webpack
npm ERR! code EPERM
npm ERR! errno -1
npm ERR! syscall rename
npm ERR! Error: EPERM: operation not permitted, rename '/vagrant/laravel/node_modules/laravel-mix/node_modules/webpack' -> '/vagrant/laravel/node_modules/laravel-mix/node_modules/.webpack.DELETE'
npm ERR!  { Error: EPERM: operation not permitted, rename '/vagrant/laravel/node_modules/laravel-mix/node_modules/webpack' -> '/vagrant/laravel/node_modules/laravel-mix/node_modules/.webpack.DELETE'
npm ERR!   cause: 
npm ERR!    { Error: EPERM: operation not permitted, rename '/vagrant/laravel/node_modules/laravel-mix/node_modules/webpack' -> '/vagrant/laravel/node_modules/laravel-mix/node_modules/.webpack.DELETE'
npm ERR!      errno: -1,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'rename',
npm ERR!      path: '/vagrant/laravel/node_modules/laravel-mix/node_modules/webpack',
npm ERR!      dest: '/vagrant/laravel/node_modules/laravel-mix/node_modules/.webpack.DELETE' },
npm ERR!   stack: 'Error: EPERM: operation not permitted, rename \'/vagrant/laravel/node_modules/laravel-mix/node_modules/webpack\' -> \'/vagrant/laravel/node_modules/laravel-mix/node_modules/.webpack.DELETE\'',
npm ERR!   errno: -1,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'rename',
npm ERR!   path: '/vagrant/laravel/node_modules/laravel-mix/node_modules/webpack',
npm ERR!   dest: '/vagrant/laravel/node_modules/laravel-mix/node_modules/.webpack.DELETE',
npm ERR!   parent: 'laravel-mix' }
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!     /root/.npm/_logs/2018-09-22T02_49_38_612Z-debug.log


当清除了cache后再次执行 npm install 报错:


npm ERR! ETXTBSY: text file is busy, rename '/vagrant/laravel/node_modules/ansi-styles/package.json.3302866204' -> '/vagrant/laravel/node_modules/ansi-styles/package.json'


搜索的方法 (地址:https://github.com/laravel/homestead/issues/922)

1、换用 yarn

2、So the good news is I've been able to confirm what you're seeing on my Windows 10 + Virtualbox machine.

The bad news is I don't think it's anything Homestead can fix. It seems to be an issue between NPM & Virtualbox.

One alternative I saw people try was using Yarn, this seemed to work for me:

vagrant@homestead:~/qs$ yarn install --no-bin-links
yarn install v1.7.0
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@1.1.2: The platform "linux" is incompatible with this module.
info "fsevents@1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
warning Your current version of Yarn is out of date. The latest version is "1.9.4", while you're on "1.7.0".
info To upgrade, run the following command:
$ curl --compressed -o- -L https://yarnpkg.com/install.sh | bash
Done in 275.46s.

If you don't want to use yarn, my best workaround suggestion would be to install NPM on your windows machine and run NPM commands from your host OS.


我更认同方法二,既然是 virtualBox 问题,所以我建议在 Windows 下安装 nodejs,然后 Windows 下执行 npm install(执行命令前,删除 package-lock.json 文件,否则报错 cannot read property match of undefined ) 


标签: npm install

评论 (0)