执行npm start启动React项目时遇nodenv版本未安装错误
No worries, this is a super common nodenv hiccup—let’s get your React project up and running in just a few steps:
Install the required Node.js version first
Your project’s.node-versionfile is telling nodenv to use Node 8.9.1, which isn’t on your system yet. Run this command in your terminal:nodenv install 8.9.1If you hit a compilation error (pretty common on macOS), make sure you have Xcode Command Line Tools installed first:
xcode-select --installFollow the on-screen prompts to finish installing, then rerun the nodenv install command.
Update nodenv’s shims
Once the version is installed, you need to let nodenv know it’s available. Run this to refresh its reference list:nodenv rehashConfirm the correct version is active
Head back to your React project directory and check the Node version with:node --versionYou should see
v8.9.1printed out. Now go ahead and runnpm start—your project should launch without that nodenv error.
Quick (But Not Recommended) Alternative
If you really don’t want to use Node 8.9.1, you can edit the .node-version file in your project root and replace 8.9.1 with a Node version you already have installed. Just keep in mind: the project was likely configured for 8.9.1, so this might lead to unexpected bugs later on.
内容的提问来源于stack exchange,提问作者Ishan Patel

