You need to enable JavaScript to run this app.
最新活动
大模型
产品
解决方案
定价
生态与合作
支持与服务
开发者
了解我们

无法执行npm install -D webpack,报EPERM(-4048)错误求助

Fixing EPERM Error When Running npm install -D webpack on Windows

Hey there, sorry you're hitting this frustrating EPERM error—especially since it was working smoothly before! Let's break down what's going on and walk through actionable fixes to get you back on track.

What's Causing This?

This error (EPERM: operation not permitted, unlink...) almost always boils down to file permission issues or files being locked by another process on Windows. The system is blocking npm from deleting/modifying a file in your node_modules folder.

Step-by-Step Fixes

1. Run Your Terminal as Administrator

The error message explicitly suggests this, so let's start here:

  • Right-click Command Prompt or PowerShell
  • Select Run as administrator
  • Navigate back to your project folder and re-run:
    npm install -D webpack
    

2. Free Up Locked Files

Windows often locks files when they're in use by other apps. Try these:

  • Close all editors/IDE windows that have your project open (like VS Code, Atom)
  • Temporarily disable your antivirus or firewall (don't forget to re-enable it afterward!)
  • Open Task Manager, go to the Processes tab, and end any running node.exe or npm.exe processes

3. Clean npm Cache & Reinstall From Scratch

Corrupted cache or leftover files can cause permission conflicts:

  1. First, clear the npm cache:
    npm cache clean --force
    
  2. Delete your project's node_modules folder and package-lock.json file
  3. Re-run the install command:
    npm install -D webpack
    

4. Verify Folder Permissions

Make sure your user account has full access to the project folder:

  • Right-click your cpay-ext folder → Properties
  • Go to the Security tab → Click Edit
  • Select your user account (Yevgeny Kozlov) → Check the box for Full Control
  • Click Apply then OK
  • Try the install command again

5. Skip Optional macOS-Specific Dependencies (fsevents)

Since you're on Windows, fsevents (a macOS-only file system watcher) is unnecessary and might be causing conflicts. You can skip installing optional dependencies:

npm install -D webpack --no-optional

Alternatively, add "fsevents": "*" to the optionalDependencies section of your package.json to mark it as optional for future installs.

If All Else Fails...

Check the detailed error log mentioned in the output:

C:\Users\Yevgeny Kozlov\AppData\Roaming\npm-cache_logs\2017-12-31T21_12_18_374Z-debug.log
This log might have more specific details about which process is locking the file or where the permission issue originates.

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

火山引擎 最新活动