You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

执行npm install失败求助:node-sass@4.9.0跨平台安装报错

Fixing npm install Failures with node-sass@4.9.0 on Node.js v12.13.0

Hey there! Let's get your npm install working smoothly. First, let's split out the harmless warnings from the actual error that's stopping your setup:

Harmless Warnings (You Can Totally Ignore These)

  • No license field: This is just a heads-up that your project's package.json doesn't have a license property defined. It won't block your install—if you want to fix it later, add something like "license": "MIT" to your package.json file.
  • fsevents skipped warnings: fsevents is a macOS-only tool for file system watching. Since you're working on Windows (and tested other OSes too), npm correctly skips installing it. No action needed here at all.

The Real Problem: node-sass@4.9.0 and Node.js v12.13.0 Don't Play Nice

The critical error breaking your install is:

Failed at the node-sass@4.9.0 postinstall script

node-sass has strict version compatibility rules with Node.js. node-sass@4.9.0 doesn't support Node.js v12.x—it only works with Node.js v8.x and v10.x. Since you're running Node v12.13.0, the postinstall build script fails every time.

Solutions to Fix This

Pick one of these approaches based on your project's needs:

1. Upgrade node-sass to a Version That Supports Node v12

node-sass@4.12.0 and newer versions work with Node.js v12. Here's how to update:

  • First, wipe your existing dependencies and lock file:
    • On Windows:
      rmdir /s node_modules
      del package-lock.json
      
    • On macOS/Linux:
      rm -rf node_modules package-lock.json
      
  • Install the compatible node-sass version:
    npm install node-sass@^4.12.0 --save-dev
    
  • Finally, run npm install again.

2. Downgrade Node.js to a Version Supported by node-sass@4.9.0

If your project relies on node-sass@4.9.0 (due to other dependency constraints), you'll need to switch to Node.js v10.x (the latest version that works with node-sass@4.9.0). Use Node Version Manager (nvm) to make this easy:

  • Install nvm (use nvm-windows for Windows, official nvm for macOS/Linux)
  • Install Node v10:
    nvm install 10
    
  • Switch to Node v10:
    nvm use 10
    
  • Now run npm install again—it should work.

3. (Windows Only) Install Build Tools If You Still Hit Errors

If version fixes don't resolve the build issue, Windows might need extra tools for node-sass to compile. Install them globally with:

npm install --global windows-build-tools

Restart your terminal after installation, then run npm install once more.


内容的提问来源于stack exchange,提问作者Ashkan Pirmani

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.14 08:58:00