Laravel 5.4配置laravel-mix时npm install报错的解决方法
Hey there, I feel your pain—node-sass installation issues can be super frustrating, especially when you're just getting started with Laravel. Let's break down what's going on and fix this step by step:
Why This Happens
The core issue here is that the node-sass@4.9.0 binary file failed to download correctly (or passed corrupted data), triggering that AssertionError when the installer tried to verify it. The peer dependency warnings are secondary, but we'll address those too.
Step-by-Step Fixes
1. Clear npm Cache & Start Fresh
First, let's wipe any corrupted cache files and reinstall dependencies from scratch:
- Open Command Prompt as Administrator (this avoids permission issues like the
EPERMwarning you saw) - Run these commands one by one:
npm cache clean --force rmdir /s /q node_modules del package-lock.json npm install
2. Use a Mirror for node-sass Binary (Most Likely Fix)
GitHub's binary servers can be flaky on Windows or certain networks. Let's force node-sass to use a reliable mirror:
- Run this command first to install node-sass with the mirror, then reinstall all dependencies:
npm install node-sass@4.9.0 --sass_binary_site=https://npm.taobao.org/mirrors/node-sass/ npm install
3. Fix the Peer Dependency Warning
The ajv-keywords@3.2.0 warning isn't breaking your install right now, but it's good to fix it to avoid future issues:
npm install ajv@^6.0.0
4. Verify Node.js Version Compatibility
node-sass@4.9.0 works best with Node.js 6.x, 7.x, or 8.x. If you're running a newer or older version, you might hit compatibility bugs:
- Check your current Node version with:
node -v - If you need to switch versions, use nvm-windows (a tool to manage multiple Node versions easily) to install Node 8.x, then retry
npm install.
Final Notes
If none of these work, try disabling any VPN or antivirus temporarily—sometimes they block the binary download. Also, make sure your Command Prompt has full read/write access to your project folder.
内容的提问来源于stack exchange,提问作者quippo

