I just created a new project using the "Basic Node.js Express 4 Application" template, and the project appears to already have errors:
Is this a bug in Visual Studio? How do I fix the errors?
I just created a new project using the "Basic Node.js Express 4 Application" template, and the project appears to already have errors:
Is this a bug in Visual Studio? How do I fix the errors?

Just Wait
When you create a new project using this template, Visual Studio runs
npm installin the background to download packages and type information from the npm registry. Until that type information is downloaded, you may temporarily see errors in the editor.Running
npm installmight take as long as 2 minutes depending on your network and disk conditions. If you don't yet see thenpm command completedmessage, thennpmis still running and you need to go grab a quick coffee. Once the install finishes, Visual Studio will automatically updated the Intellisense errors.Waiting Didn't Work?
If you've waited a little and the errors are still there, the first step to diagnosing the problem is to check the
Outputwindow to see how thenpm installis going. From the top menu, selectView->Output, then in the Output Window, selectNpmin the combo box labeledShow output from:What you do next depends on what you see in the output window.
Try Again
Due to a bug in the interaction between npm's staging behavior,
graceful-fs, and the Win32MoveFileExAPI,npm installmay randomly fail. You'll see an error trace in the Output Window that looks like this:DO NOT follow npm's suggestion to re-run the command as an Administrator; this will only make things worse. Run
npm installfrom a regular commandline, or equivalently, selectInstall Missing npm Packagesfrom thenpmnode in the Solution Explorer:Note that this will run
npm install, which may fail again (but probably won't).Close the Solution
A small portion of users have seen
npm installfail repeatedly. In the very unlikely event this fails again, you can try closing the solution, runningnpm installfrom the commandline, and re-opening the solution, but in general this should not be necessary. Ifnpm installfails even with Visual Studio not running, then you likely have another problem, such as a corrupted npm cache, disk error, or some other npm bug not covered by this answer.Consider Downgrading or Upgrading npm
The bug causing the
EPERMerrors was introduced innpmversion 5, so if this is somehow causing serious problems for you, you can consider downgrading to any 4.x.x version. At time of writing the bug has not been fixed, but hopefully in the future a new version of npm with thegraceful-fsbug fix will be released and you can simply upgrade.