用npm安装依赖有时候会有各种的问题,下面的只是两个例子
error An unexpected error occurred: “EPERM: operation not permitted, unlink ‘E:\xx\node_modules\node-sass\vendor\win32-x64-83\binding.node’”.
info If you think this is a bug, please open a bug report with the information provided in “E:\xx\yarn-error.log”.
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\xx\AppData\Roaming\npm-cache_logs\2022-03-23T05_52_40_678Z-debug.log
总结下来一般这几种方法可以解决:
在cmd中以管理员身份运行,不要在vscode的终端中运行
1.删除node_modules包
2.用 npm cache clean --force清除缓存
执行了上面两步,如果用npm不行的话,再执行一次上面两步之后用yarn install安装
如果都不行的话,执行完上面两步之后,执行第三步
3. 删除C:\Users\用户名\ 下的.npmrc 这个文件
之后再安装依赖
error An unexpected error occurred: “https://registry.npmjs.org/@ant-design/icons-svg/-/icons-svg-4.2.1.tgz: ESOCKETTIMEDOUT”.
出现这种情况的报错一般是网络问题,再重新安装一遍就好了