Homestead虚拟机中执行npm install后npm ERR! 解决方案

npm ERR! Linux 4.4.0-51-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install" "--no-bin-links"
npm ERR! node v6.9.2
npm ERR! npm  v4.0.5

npm ERR! Maximum call stack size exceeded
npm ERR! 
npm ERR! If you need help, you may report this error at:
npm ERR!     <https://github.com/npm/npm/issues>

npm ERR! Please include the following file with any support request:
npm ERR!     /home/vagrant/Code/sample/npm-debug.log

在网上找了一下解决方法,记录一下。

1.如果node.js版本不是最新的,可按照官网相关命令安装最新版本。目前版本6.x

curl -sL https://deb.nodesource.com/setup_6.x | sudo -E bash -
sudo apt-get install -y nodejs

2.更新npm至最新版本

sudo npm -g install npm@latest

3.切换到项目目录下,执行以下命令

sudo npm cache clear
sudo npm install --force --no-bin-links

4.错误解决之后,在项目目录下执行gulp命令,可能会有以下错误提示

gulp
vagrant@homestead:~/Code/sample$ gulp
[01:48:40] Using gulpfile ~/Code/sample/gulpfile.js
[01:48:40] Starting 'default'...
[01:48:40] Starting 'sass'...
[01:48:40] 'sass' errored after 142 ms
[01:48:40] Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/sample/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/sample/node_modules/node-sass/lib/extensions.js:121:13)
    at foundBinariesList (/home/vagrant/Code/sample/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/sample/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/sample/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/sample/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/sample/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
[01:48:40] Error in plugin 'run-sequence(sass)'
Message:
    ENOENT: no such file or directory, scandir '/home/vagrant/Code/sample/node_modules/node-sass/vendor'
Details:
    errno: -2
    code: ENOENT
    syscall: scandir
    path: /home/vagrant/Code/sample/node_modules/node-sass/vendor
Stack:
Error: ENOENT: no such file or directory, scandir '/home/vagrant/Code/sample/node_modules/node-sass/vendor'
    at Error (native)
    at Object.fs.readdirSync (fs.js:951:18)
    at Object.getInstalledBinaries (/home/vagrant/Code/sample/node_modules/node-sass/lib/extensions.js:121:13)
    at foundBinariesList (/home/vagrant/Code/sample/node_modules/node-sass/lib/errors.js:20:15)
    at foundBinaries (/home/vagrant/Code/sample/node_modules/node-sass/lib/errors.js:15:5)
    at Object.module.exports.missingBinary (/home/vagrant/Code/sample/node_modules/node-sass/lib/errors.js:45:5)
    at module.exports (/home/vagrant/Code/sample/node_modules/node-sass/lib/binding.js:15:30)
    at Object.<anonymous> (/home/vagrant/Code/sample/node_modules/node-sass/lib/index.js:14:35)
    at Module._compile (module.js:570:32)
    at Object.Module._extensions..js (module.js:579:10)
[01:48:40] Finished 'default' after 172 ms

5.此时需要rebuild node-sass

sudo npm rebuild node-sass --no-bin-links

此时一切恢复正常

vagrant@homestead:~/Code/sample$ gulp
[02:11:24] Using gulpfile ~/Code/sample/gulpfile.js
[02:11:24] Starting 'default'...
[02:11:24] Starting 'sass'...

Fetching Sass Source Files...
   - resources/assets/sass/app.scss


Saving To...
   - public/css/app.css

[02:11:42] Finished 'default' after 18 s
[02:11:44] gulp-notify: [Laravel Elixir] Sass Compiled!
[02:11:44] Finished 'sass' after 20 s

 

转载于:https://my.oschina.net/Chinapap/blog/810135

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值