npm错误!错误:EPERM:操作不允许,解除链接。

5
  • 操作系统:Windows 10。
  • npm版本:6.9.0
  • node版本:12.4.0

我正在开发一个Expo应用程序。 我想要安装我的Expo应用程序中的所有软件包(npm install)。但是,出现了错误:

17254 error [OperationalError: EPERM: operation not permitted, unlink ... 我在许多主题上看到过这个错误,但没有人回答我的问题。

我已经尝试过:

  1. 以管理员身份启动终端。
  2. npm config set safe-perm=true。
  3. npm install --no-bin-links
  4. npm cache clear --force

我遇到的错误消息示例:

17254 error   cause: [Error: EPERM: operation not permitted, unlink 'C:\Users\Thomas\Desktop\someDirectory\someDirectory\someDirectory\someDirectory\node_modules\.staging\react-native-99ed309f\Libraries\Renderer\oss\ReactFabric-dev.js'] {
17254 error     errno: -4048,
17254 error     code: 'EPERM',
17254 error     syscall: 'unlink',
17254 error     path: 'C:\\Users\\Thomas\\Desktop\\someDirectory\\someDirectory\\someDirectory\\someDirectory\\node_modules\\.staging\\react-native-99ed309f\\Libraries\\Renderer\\oss\\ReactFabric-dev.js'
17254 error   },
17254 error   stack: 'Error: EPERM: operation not permitted, unlink ' +
17254 error     "'C:\\Users\\Thomas\\Desktop\\someDirectory\\someDirectory\\someDirectory\\someDirectory\\node_modules\\.staging\\react-native-99ed309f\\Libraries\\Renderer\\oss\\ReactFabric-dev.js'",
17254 error   errno: -4048,
17254 error   code: 'EPERM',
17254 error   syscall: 'unlink',
17254 error   path: 'C:\\Users\\Thomas\\Desktop\\someDirectory\\someDirectory\\someDirectory\\someDirectory\\node_modules\\.staging\\react-native-99ed309f\\Libraries\\Renderer\\oss\\ReactFabric-dev.js'
17254 error }
17255 error The operation was rejected by your operating system.
17255 error It's possible that the file was already in use (by a text editor or antivirus),
17255 error or that you lack permissions to access it.
17255 error
17255 error If you believe this might be a permissions issue, please double-check the
17255 error permissions of the file and its containing directories, or try running
17255 error the command again as root/Administrator (though this is not recommended).
17256 verbose exit [ -4048, true ] ```

'Libraries'目录不存在,确实如此。但是这个错误也会发生在存在的目录上,比如'RnTester-js-Tester App.ios',但是里面的文件不存在。 - Thomsath
你可以在这个帖子中找到很多解决方案,你可以去看看。 - Jeppe
清理构建文件夹并重新构建有所帮助 - Saahithyan Vigneswaran
5个回答

8

是否有另一个正在运行的node实例,也在使用ReactFabric-dev.js?如果是这样,请终止并重试。还可以尝试将项目移动到更接近根目录的文件夹中。Windows有时会对非常长的路径感到困惑。


我的电脑上没有运行另一个节点实例。我已经重启了它,但什么都没有改变... - Thomsath

4
通过登录npmjs来解决问题: npm login 或者
卸载所有的npm模块,并使用 npm install --no-bin-links 重新安装。
或者
rd /s /q C:\Users\foo\AppData\Roaming\npm-cache
rd /s /q C:\Users\foo\AppData\Roaming\npm

3

我所做的是:

  1. 删除了node_modules文件夹;

  2. 以管理员身份打开了VSCode;

  3. 在终端中运行了以下命令:

    npm cache clean --force

    npm install


1
要求使用VSCode终端可能会有点令人困惑。据我所见,只要以管理员身份运行的任何终端都可以。 - shaedrich

2

我遇到了这个错误信息,要解决它,您需要:

1)将您的项目文件夹添加到Windows Defender排除列表中。

2)删除您的node_modules文件夹

3)运行:

最初的回答:

npm install

0

首先尝试使用以下命令在全局安装:

  • npm install -g create-react-app

然后,您可以使用以下命令来创建您的应用程序:

  • npx create-react-app <Name_of_your_app>

网页内容由stack overflow 提供, 点击上面的
可以查看英文原文,
原文链接