Visual Studio Installer安装Node.js后无法使用及Angular项目启动失败求助
Hey Richard, let's work through this Node.js and VS 2017 issue step by step—sounds like your setup is tangled between the bundled VS version and the standalone one you installed. Here's what I'd recommend trying to get everything working smoothly:
First, let's make sure your system is using the right Node.js version:
- Open Command Prompt as Administrator and run
echo %PATH%to see all the paths in your system's PATH variable. - VS 2017 usually tucks its bundled Node.js under a path like
C:\Program Files (x86)\Microsoft Visual Studio\2017\Community\Web\External(swap "Community" for "Professional" or "Enterprise" if that's your edition). - The official Node.js you installed is likely in
C:\Program Files\nodejsorC:\Program Files (x86)\nodejs. - Critical step: The official Node.js path needs to come BEFORE the VS bundled path in the PATH list. To fix this:
- Right-click "This PC" > Properties > Advanced System Settings > Environment Variables.
- Under System Variables, find
Path, click Edit. - Move the official Node.js entry to the top of the list, then save all changes.
- Close all open cmd windows, reopen one, and test
node -vagain—it should now show the version you installed from the official site.
VS might still be trying to use its own bundled version, so let's adjust its settings:
- Open VS 2017, go to Tools > Options > Projects and Solutions > Web Package Management > External Web Tools.
- You'll see a list of paths VS uses for tools like Node.js and npm.
- Drag the path to your official Node.js installation (e.g.,
C:\Program Files\nodejs) above all the VS-specific paths (like$(VSInstallDir)\Web\External). - Click OK, then restart VS to apply the changes.
Cached dependencies or build artifacts could be causing the startup failure:
- In VS, right-click your solution > Clean Solution to wipe old build files.
- Then right-click again > Rebuild Solution to start fresh.
- If that still doesn't work, open a cmd window in your solution's root folder (where
package.jsonlives) and run these commands directly:
This bypasses VS's build system temporarily to see if the app can start directly with your Node.js setup.npm install npm start
If the above steps don't fix it, a clean slate might help:
- Uninstall the Node.js development workload via Visual Studio Installer.
- Uninstall the standalone Node.js from Control Panel > Programs and Features.
- Delete any leftover Node.js folders:
C:\Program Files\nodejsC:\Program Files (x86)\nodejsC:\Users\<YourUsername>\AppData\Roaming\npmC:\Users\<YourUsername>\AppData\Roaming\npm-cache
- Restart your computer.
- First install the official Node.js, then add the Node.js development workload back in VS Installer. This ensures the official version is the primary one from the start.
Corrupted npm cache can break dependency installs. Run these commands in cmd:
npm cache clean --force npm install -g npm@latest
This clears the cache and updates npm to the latest version, which often resolves hidden dependency conflicts.
After working through these steps, test node -v again in cmd, then try launching the Angular solution in VS 2017. Most of the time, PATH ordering or VS's external tool settings are the root cause here.
内容的提问来源于stack exchange,提问作者Richard

