npmError: EPERM: operation not permitted,...

create-react-app react-antd-demo
cd react-antd-demo
npm run start

想使用antd,安装antd

npm install antd

直接报错:
npm ERR! Error: EPERM: operation not permitted, unlink ‘e:\Users\zoe\Desktop\ReactStudy\antd-hooks-demo
\node_modules.staging\antd-bc74d47f\dist\antd.js’
npm ERR! [OperationalError: EPERM: operation not permitted, unlink ‘e:\Users\zoe\Desktop\ReactStudy\an
td-hooks-demo\node_modules.staging\antd-bc74d47f\dist\antd.js’] {
npm ERR! cause: [Error: EPERM: operation not permitted, unlink ‘e:\Users\zoe\Desktop\ReactStudy\antd-
hooks-demo\node_modules.staging\antd-bc74d47f\dist\antd.js’] {
npm ERR! errno: -4048,
npm ERR! code: ‘EPERM’,

下载不成功,所以,做了如下操作:

  1. 删除项目中node_modules
  2. 清除npm缓存 …

清除缓存的方式有两种:
第一种是直接删除缓存文件,找到C盘下我的用户名下的.npmrc文件删除即可。
第二种是执行:npm cache clean --force,同样达到清除缓存文件的目的。

清除后,重新安装就行了。

npm install
npm install antd 

你可能感兴趣的:(react,bug)