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

如何在Mac OS X开机时启动Verdaccio(Sinopia分支)?已试.plist文件无效

Fixing Verdaccio Auto-Start via LaunchDaemon on macOS

Hey there, let's get your Verdaccio setup to auto-start on boot sorted out. Launchd can be finicky with plists, so let's walk through the most common issues and fixes step by step:

1. First, Use a Valid Launchd Plist Template

Your existing plist might have syntax errors or missing critical keys. Here's a tested template you can adapt (save it as /Library/LaunchDaemons/com.npm.verdaccio.plist):

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
    <key>Label</key>
    <string>com.npm.verdaccio</string> <!-- Unique identifier, use reverse domain format -->
    <key>ProgramArguments</key>
    <array>
        <string>/usr/local/bin/verdaccio</string> <!-- Use `which verdaccio` to get your actual path -->
        <!-- Uncomment below if you need to specify a custom config file (use ABSOLUTE path, no ~) -->
        <!-- <string>-c</string> -->
        <!-- <string>/Users/yourusername/.config/verdaccio/config.yaml</string> -->
    </array>
    <key>RunAtLoad</key>
    <true/> <!-- Start when the system boots -->
    <key>KeepAlive</key>
    <dict>
        <key>SuccessfulExit</key>
        <false/> <!-- Restart Verdaccio if it crashes unexpectedly -->
    </dict>
    <key>StandardOutPath</key>
    <string>/var/log/verdaccio.log</string> <!-- Log output for debugging -->
    <key>StandardErrorPath</key>
    <string>/var/log/verdaccio-error.log</string> <!-- Log errors separately -->
    <key>EnvironmentVariables</key>
    <dict>
        <key>PATH</key>
        <string>/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin</string> <!-- Ensure launchd can find Node/Verdaccio -->
    </dict>
</dict>
</plist>

2. Fix Permissions & Ownership

LaunchDaemons require strict permissions to run. Run these commands to set them correctly:

sudo chown root:wheel /Library/LaunchDaemons/com.npm.verdaccio.plist
sudo chmod 644 /Library/LaunchDaemons/com.npm.verdaccio.plist

3. Validate the Plist Syntax

A tiny typo can break everything. Use plutil to check for errors:

plutil /Library/LaunchDaemons/com.npm.verdaccio.plist

If it returns "OK", your syntax is good. If not, it'll point you to the line with the issue.

4. Test Manually Before Rebooting

Don't wait for a reboot to test. Load the daemon manually and check if it runs:

sudo launchctl load /Library/LaunchDaemons/com.npm.verdaccio.plist

Then verify it's running:

ps aux | grep verdaccio

If it's not running, check the log files you specified (/var/log/verdaccio-error.log) or system logs with:

log show --predicate 'process == "verdaccio"' --info

5. Common Gotchas to Check

  • Absolute Paths Only: Launchd doesn't recognize ~ or relative paths. Make sure all paths (Verdaccio executable, config file, logs) are absolute.
  • Environment Variables: If Verdaccio relies on specific env vars (like NODE_PATH), add them to the EnvironmentVariables dict in the plist.
  • User Context: LaunchDaemons run as root. If your Verdaccio config uses files owned by your user, you might need to add a UserName key to the plist to run it as your user instead (replace yourusername):
    <key>UserName</key>
    <string>yourusername</string>
    

Once everything works, you can set it to auto-load on boot permanently:

sudo launchctl enable system/com.npm.verdaccio

内容的提问来源于stack exchange,提问作者Igor de Oliveira Sá

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.20 10:07:12