The EPERM error in npm when using TFS and Visual Studio and how to solve it

When you work with Team Foundation Server (TFS) and Visual Studio and you do web development, chances are that you will come across the EPERM error when npm tries to change a file in your application. The complete error message is Error: EPERM: operation not permitted, rename and then the absolute path to the problematic file follows.

In most of the cases the file that npm tries to automatically change, for example the dependencies in the package.json file when a new npm plugin is being installed, is a file that is checked in TFS and this make the file read only. This file can be changed only if it is checked out for changes.

So here you go, the next time you come across the EPERM: operation not permitted error, check which files generates the error and then check this file out, so that the file can be changed from npm.

comments powered by Disqus