npm install 报错(npm ERR! errno -4048,Error: EPERM: operation not permitted,)解决方法

首先遇到这种问题是分两种用户,一种是windows操作系统,另一种是苹果电脑的用户

苹果用户碰到这种问题就很好解决了,通过终端找到npm install 的全局路径,chmod -R 777 获取提示的那个文件夹的权限就可以

windows的用户就按下面的方式来解决

如果解决不了就把WebStorm关掉,用终端输入对应的命令,不要用WebStorm里面的终端

(在对应的文件夹下按shift+鼠标右键,在此处打开命令窗口!!)

npm ERR! path E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir ‘E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules’
npm ERR!  { Error: EPERM: operation not permitted, scandir ‘E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules’
npm ERR!   stack: ‘Error: EPERM: operation not permitted, scandir \’E:\\SouthernPowerGridProject\\web_project\\AutoOPS\\autoops\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules\”,
npm ERR!   errno: -4048,
npm ERR!   code: ‘EPERM’,
npm ERR!   syscall: ‘scandir’,
npm ERR!   path: ‘E:\\SouthernPowerGridProject\\web_project\\AutoOPS\\autoops\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.


npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ThinkT420\AppData\Roaming\npm-cache\_logs\2017-10-30T06_50_38_610Z-debug.log



之前有时报这个,以为还真是权限不够,感觉有点奇怪,用管理员权限执行,有时还真有用,不过后面查了下,时缓存的问题,清理下缓存就行,不用管理员权限。

方法1、

需要删除npmrc文件。

强调:不是nodejs安装目录npm模块下的那个npmrc文件

而是在C:\Users\{账户}\下的.npmrc文件..

方法2、

或者直接用命令清理就行,控制台输入:

npm cache clean –force



added 114 packages in 42.369s
E:\SouthernPowerGridProject\web_project\AutoOPS\autoops>npm cache clean –force
npm WARN using –force I sure hope you know what you are doing.


E:\SouthernPowerGridProject\web_project\AutoOPS\autoops>npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32”,”arch”:”x64”})


added 114 packages in 42.369s

成功了

  • Ran reactive-native init in command prompt as Administrator (on Windows OS), hoping works well with sudo reactive-native init on Mac OS
  • Ran npm cache clean command in Command prompt.
  • Disable your antivirus for time being.

npm ERR! path E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules
npm ERR! code EPERM
npm ERR! errno -4048
npm ERR! syscall scandir
npm ERR! Error: EPERM: operation not permitted, scandir ‘E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules’
npm ERR!  { Error: EPERM: operation not permitted, scandir ‘E:\SouthernPowerGridProject\web_project\AutoOPS\autoops\node_modules\fsevents\node_modules\dashdash\node_modules’
npm ERR!   stack: ‘Error: EPERM: operation not permitted, scandir \’E:\\SouthernPowerGridProject\\web_project\\AutoOPS\\autoops\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules\”,
npm ERR!   errno: -4048,
npm ERR!   code: ‘EPERM’,
npm ERR!   syscall: ‘scandir’,
npm ERR!   path: ‘E:\\SouthernPowerGridProject\\web_project\\AutoOPS\\autoops\\node_modules\\fsevents\\node_modules\\dashdash\\node_modules’ }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.


npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\ThinkT420\AppData\Roaming\npm-cache\_logs\2017-10-30T06_50_38_610Z-debug.log


E:\SouthernPowerGridProject\web_project\AutoOPS\autoops>npm cache clean –force
npm WARN using –force I sure hope you know what you are doing.


E:\SouthernPowerGridProject\web_project\AutoOPS\autoops>npm install
npm notice created a lockfile as package-lock.json. You should commit this file.
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {“os”:”darwin”,”arch”:”any”} (current: {“os”:”win32”,”arch”:”x64”})


added 114 packages in 42.369s
            </div>
                </div>
### 关于 `npm` 错误解决方案 #### 语法错误:`SyntaxError: Unexpected token ?` 如果在运行命令 `npm create vue@latest` 后遇到了 `SyntaxError: Unexpected token ?` 的错误,这通常是因为当前使用的 Node.js 版本过低所致。Vue CLI 创建工具可能依赖较新的 JavaScript 功能(如可选链操作符 `?.`),而这些功能仅支持更高版本的 Node.js 和 NPM[^1]。 为了修复此问题,可以尝试升级 Node.js 到最新稳定版: ```bash nvm install --lts nvm use --lts ``` 确认安装完成后,重新初始化项目即可解决问题。 --- #### 报错:`Unable to run npm install` 当遇到 `Unable to run npm install` 或类似的错误时,通常是由于以下原因之一引起的: 1. **Node.js/NPM 版本不兼容** 如果目标环境中使用的是旧版本的 Node.js 或 NPM,则可能导致某些模块无法正常解析或安装。建议更新至最新的 LTS 版本来确保兼容性[^2]。 2. **网络连接不稳定** 部分情况下,NPM 安装失败可能是由代理设置不当或者国内访问国外资源受限引起。可以通过配置淘宝镜像来加速安装过程: ```bash npm config set registry https://registry.npmmirror.com/ ``` 3. **权限不足** 若是在生产服务器上执行该命令,可能会因为文件夹写入权限不够而导致失败。此时需切换到具有管理员权限的账户下重试,或者通过指定路径的方式绕开默认全局存储位置。 --- #### 错误码 `errno 126` 对于 `errno 126` 类型的问题,在 CentOS 上部署 Vue 应用程序时尤为常见。其根本原因是本地缓存损坏或者是特定平台上的二进制依赖项缺失所引发的一系列连锁反应[^3]。 以下是具体的处理流程: 1. 删除现有的 `node_modules` 文件夹以及锁定文件以移除潜在冲突; ```bash rm -rf node_modules package-lock.json ``` 2. 清理 NPM 缓存以防残留数据干扰新组件加载; ```bash npm cache clear --force ``` 3. 使用干净的状态重新构建整个依赖树结构; ```bash npm install && npm audit fix ``` 完成上述步骤之后再次尝试打包应该能够恢复正常运作状态。 --- ### 总结 针对不同类型的 `npm` 错误,采取相应的措施非常重要。无论是调整基础环境还是优化现有工作流中的细节部分都可以有效减少此类异常的发生频率。务必保持软件栈始终处于良好维护之下,并定期审查日志记录以便及时发现隐患所在之处。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值