npm / cli

the package manager for JavaScript
https://docs.npmjs.com/cli/
Other
8.53k stars 3.2k forks source link

[gatsby-plugin-netlify-cms] Unable to install the plugin to the Gatsby blog #1564

Closed mohammedasker closed 4 years ago

mohammedasker commented 4 years ago

Hi, someone forwards me to this repository because they believe it is npm issue and so I hope anyone would help me fix the problem. The original question appeared in Gatsby issues.

Description

I am unable to install the Gatsby plugin for Netlify CMS to my blog. I've been following a tutorial of adding Netlify CMS to existing blog and also referred to this doc.

Steps to reproduce

Here's a link to my repo: https://github.com/mohammedasker/blogger

  1. Clone my repo and head to the project directory
  2. run npm install --save netlify-cms-app gatsby-plugin-netlify-cms

Expected result

Gatsby plugin for Netlify CMS installed successfully.

Actual result

Error in installing Gatsby plugin for Netlify CMS.

Here's the error log I got from the terminal:

npm ERR! code EPERM
npm ERR! syscall unlink
npm ERR! path C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist
npm ERR! errno -4048
npm ERR! Error: EPERM: operation not permitted, unlink 'C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist'
npm ERR!  [OperationalError: EPERM: operation not permitted, unlink 'C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist'] {
npm ERR!   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\User\Desktop\Mohd Projects\blogger\node_modules\@emotion\weak-memoize\dist'] {
npm ERR!     errno: -4048,
npm ERR!     code: 'EPERM',
npm ERR!     syscall: 'unlink',
npm ERR!     path: 'C:\\Users\\User\\Desktop\\Mohd Projects\\blogger\\node_modules\\@emotion\\weak-memoize\\dist'
npm ERR!   },
npm ERR!   stack: "Error: EPERM: operation not permitted, unlink 'C:\\Users\\User\\Desktop\\Mohd Projects\\blogger\\node_modules\\@emotion\\weak-memoize\\dist'",
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'unlink',
npm ERR!   path: 'C:\\Users\\User\\Desktop\\Mohd Projects\\blogger\\node_modules\\@emotion\\weak-memoize\\dist',
npm ERR!   parent: 'blogger'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.

Environment

 System:
    OS: Windows 10 10.0.18363
    CPU: (4) x64 Intel(R) Core(TM) i5-7200U CPU @ 2.50GHz
  Binaries:
    Node: 12.13.0 - C:\Program Files\nodejs\node.EXE
    Yarn: 1.21.1 - ~\scoop\apps\yarn\current\Yarn\bin\yarn.CMD
    npm: 6.12.0 - C:\Program Files\nodejs\npm.CMD
  Browsers:
    Edge: 44.18362.449.0
  npmPackages:
    gatsby: ^2.23.18 => 2.24.11
    gatsby-image: ^2.4.12 => 2.4.13
    gatsby-plugin-emotion: ^4.3.9 => 4.3.10
    gatsby-plugin-manifest: ^2.4.17 => 2.4.21
    gatsby-plugin-netlify: ^2.3.10 => 2.3.11
    gatsby-plugin-offline: ^3.2.16 => 3.2.21
    gatsby-plugin-react-helmet: ^3.3.9 => 3.3.10
    gatsby-plugin-sharp: ^2.6.17 => 2.6.22
    gatsby-remark-prismjs: ^3.5.9 => 3.5.10
    gatsby-remark-reading-time: ^1.1.0 => 1.1.0
    gatsby-source-filesystem: ^2.3.18 => 2.3.23
    gatsby-transformer-remark: ^2.8.23 => 2.8.27
    gatsby-transformer-sharp: ^2.5.10 => 2.5.11
  npmGlobalPackages:
    gatsby-cli: 2.12.60
mohammedasker commented 4 years ago

Update: I manage to solve it by closing the gatsby server and then running the Gatsby plugin for Netlify CMS again. The cause of the issue is when the server is running, it won't be able to install any plugins unless the server is closed. The hint is in this part from the terminal:

npm ERR! The operation was rejected by your operating system.
npm ERR! It's possible that the file was already in use (by a text editor or antivirus),
npm ERR! or that you lack permissions to access it.

So the key is I should install the plugins first before running gatsby server