— Gatsby — 1 min read
When I tried to install the Gatsby plugin for Netlify CMS
to one of my Gatsby projects, the installation has failed and generated error messages in my terminal log.
Here's the error log I got from the terminal:
1npm ERR! code EPERM2npm ERR! syscall unlink3npm ERR! path C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist4npm ERR! errno -40485npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist'6npm ERR! [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist'] {7npm ERR! cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist'] {8npm ERR! errno: -4048,9npm ERR! code: 'EPERM',10npm ERR! syscall: 'unlink',11npm ERR! path: 'C:\\Users\\User\\Desktop\\Mohd Projects\\blogger\\node_modules\\@emotion\\weak-memoize\\dist'12npm ERR! },13npm ERR! stack: "Error: EPERM: operation not permitted, unlink 'C:\\Users\\User\\Desktop\\Mohd Projects\\blogger\\node_modules\\@emotion\\weak-memoize\\dist'",14npm ERR! errno: -4048,15npm ERR! code: 'EPERM',16npm ERR! syscall: 'unlink',17npm ERR! path: 'C:\\Users\\User\\Desktop\\Mohd Projects\\blogger\\node_modules\\@emotion\\weak-memoize\\dist',18npm ERR! parent: 'blogger'19npm ERR! }20npm ERR!21npm ERR! The operation was rejected by your operating system.22npm ERR! It's possible that the file was already in use (by a text editor or antivirus),23npm ERR! or that you lack permissions to access it.24npm ERR!25npm ERR! If you believe this might be a permissions issue, please double-check the26npm ERR! permissions of the file and its containing directories, or try running27npm ERR! the command again as root/Administrator.
After asking around on Stack Overflow, it turns out the problem is when running gatsby develop
I am reading my node_modules folder since a lot of its functionalities is using it such as imports, live reload, and so on.
While a program is reading those files, the system is not able to overwrite or add new folders from other sources (which in my case is npm) and this is because my operating system is using them at a time.
The hint to the problem is reading from this particular log:
1npm ERR! The operation was rejected by your operating system.2npm ERR! It's possible that the file was already in use (by a text editor or antivirus),3npm ERR! or that you lack permissions to access it.
Therefore, to fix the error, all I had to do stop running Gatsby server and try to install the plugin again but this time without running gatsby develop
.
And it worked.
So yes, if you are unable to install a plugin for your Gatsby project, then installing the plugin first before running the server will probably solve the problem.