首页 > 解决方案 > npm install gatsby-plugin-styled-components 出错

问题描述

我正在尝试安装这些 npm 包

npm install --save gatsby-plugin-styled-components styled-components babel-plugin-styled-components

我正在使用节点版本10.11.0

但是我收到以下错误,我尝试在管理员模式下在 power-shell 中运行它没有任何区别

npm ERR! path C:\Users\Anders\sites\pro-gatsby\node_modules\@types\events\npm-shrinkwrap.json
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall open
npm ERR! Error: EPERM: operation not permitted, open 'C:\Users\Anders\sites\pro-gatsby\node_modules\@types\events\npm-shrinkwrap.json'
npm ERR!  { [Error: EPERM: operation not permitted, open 'C:\Users\Anders\sites\pro-gatsby\node_modules\@types\events\npm-shrinkwrap.json']
npm ERR!   cause:
npm ERR!    { Error: EPERM: operation not permitted, open 'C:\Users\Anders\sites\pro-gatsby\node_modules\@types\events\npm-shrinkwrap.json'
npm ERR!      errno: -4048,
npm ERR!      code: 'EPERM',
npm ERR!      syscall: 'open',
npm ERR!      path:
npm ERR!       'C:\\Users\\Anders\\sites\\pro-gatsby\\node_modules\\@types\\events\\npm-shrinkwrap.json' },
npm ERR!   isOperational: true,
npm ERR!   stack:
npm ERR!    'Error: EPERM: operation not permitted, open \'C:\\Users\\Anders\\sites\\pro-gatsby\\node_modules\\@types\\events\\npm-shrinkwrap.json\'',
npm ERR!   errno: -4048,
npm ERR!   code: 'EPERM',
npm ERR!   syscall: 'open',
npm ERR!   path:
npm ERR!    'C:\\Users\\Anders\\sites\\pro-gatsby\\node_modules\\@types\\events\\npm-shrinkwrap.json',
npm ERR!   parent: '@types/glob' }
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 (though this is not recommended).

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\Anders\AppData\Roaming\npm-cache\_logs\2018-10-20T22_44_07_361Z-debug.log

标签: node.jsnpm

解决方案


  1. 删除 node_modules
  2. npm cache clean
  3. 尝试重新安装

应该有帮助。


推荐阅读