Mac Catalina下MDC 101教程npm install及启动报错求助
Hey there, let's break down what went wrong with your MDC 101 project on Mac Catalina, why your final fix worked, and why the tutorial's default setup ran into issues:
1. Why fsevents@1.2.7 failed to install
fsevents is a macOS-specific package that handles file system events. The 1.2.7 version is pretty outdated—its precompiled binary builds don't support Mac Catalina's system environment, especially if you're running a newer Node.js version. Node.js updates often bring changes to the V8 engine API, and the old source code for fsevents@1.2.7 uses V8 API calls that are no longer valid in newer Node versions, leading to compile errors.
Your fix of running npm i fsevents@latest -f --save-optional was spot-on: the latest fsevents versions are updated to work with Catalina and modern Node.js, and --save-optional ensures it only installs on macOS (its intended use case).
2. Why fibers@4.0.1 caused compilation failures
Fibers is a package that lets you write synchronous-looking code for asynchronous operations. Like fsevents, version 4.0.1 is outdated and not compatible with the V8 API included in Node.js versions that run smoothly on Catalina. When npm tried to compile it from source, the old API calls in fibers' code clashed with the current V8 engine, resulting in a failed build. That's why you got the "binary missing" error when trying to start the service—fibers couldn't generate the required binary file for your system.
3. Why uninstalling and reinstalling fibers fixed things
When you ran npm uninstall fibers && npm install fibers, npm pulled the latest version of fibers that's compatible with your current Node.js and Catalina setup (assuming the tutorial's package.json doesn't lock fibers to an extremely old version). The updated fibers code has been patched to work with modern V8 API changes, so it compiled successfully this time. Running npm install afterward ensured all other dependencies were set up correctly, letting your service start without issues.
Why the tutorial project didn't work out of the box
The MDC 101 tutorial was likely written with older versions of Node.js and macOS in mind. Over time, as Node.js updated its V8 engine and macOS released new versions (like Catalina), the dependency versions specified in the tutorial's package.json became outdated. These old dependencies weren't maintained to support the new system and runtime environments, leading to the compilation errors you encountered.
- When you hit compilation errors for binary packages, first check the package's GitHub issues to see if other users have reported compatibility problems with your OS/Node version.
- For optional platform-specific packages like fsevents, always install the latest compatible version with
--save-optionalto avoid unnecessary cross-platform issues. - For packages like fibers that rely on V8 API, uninstalling and reinstalling often triggers npm to fetch a version that's compatible with your current environment (as long as the package.json doesn't pin an unworkable old version).
内容的提问来源于stack exchange,提问作者Gayan Kalinga

