NPM:ENOENT:没有这样的文件或目录,重命名

时间:2018-04-04 12:37:05

标签: npm npm-install npm-scripts

我在项目上使用gulp,然后我决定删除所有dev依赖项以切换到webpack,但每次我尝试使用npm安装时都会收到此错误:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.3 (node_modules\fsevents):
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\fsevents-e80c4ef4\node_modules\are-we-there-yet' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\are-we-there-yet-5db4c798'

npm ERR! path C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\acorn
npm ERR! code ENOENT
npm ERR! errno -4058
npm ERR! syscall rename
npm ERR! enoent ENOENT: no such file or directory, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\acorn' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.acorn.DELETE'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in:
npm ERR!     C:\Users\MiguelFrias\AppData\Roaming\npm-cache\_logs\2018-04-04T11_54_23_587Z-debug.log

知道会发生什么。

18 个答案:

答案 0 :(得分:9)

只需删除 package-lock.json文件,然后安装软件包,这就是您想要的并且应该可以使用

rm package-lock.json && npm i

答案 1 :(得分:3)

我正在使用
-节点 v15.5.0

-npm v6.14.10

试试这个:

  1. 关闭“博览会开始”
  2. 删除 "package-lock.json"
  3. 立即尝试安装软件包

示例:npm i @react-navigation/native

这将解决问题。

答案 2 :(得分:1)

我删除了 node_modulespackage_lock.json。然后,npm install 就可以了

答案 3 :(得分:1)

当我收到此错误时,我在任务管理器中查找了所有正在运行的节点实例(我在Windows上使用了进程浏览器),并关闭/杀死了所有正在运行的节点实例。对我来说,它经常是网络风暴或vs代码。关闭这些程序并确保没有正在运行的节点进程后,npm install再次起作用。

答案 4 :(得分:1)

缓存验证命令为我解决了该问题

npm cache verify

答案 5 :(得分:0)

您可以尝试使用命令rm package-lock.json删除package-lock.json,然后转到LTS进入Node.JS网站进行“安装”,然后在更新节点后运行npm install在您的终端上,对我有用。

答案 6 :(得分:0)

我在 Ubuntu wsl 中运行命令但它不起作用所以我尝试在 cmd 提示符下运行并且它起作用

答案 7 :(得分:0)

如果您遇到此错误,修复程序是按照以下步骤操作:

删除节点模块文件夹 运行命令 npm cache clean --force 运行命令 npm install 再次使用 npm install your-package-name 安装包

答案 8 :(得分:0)

只需将节点更新到最新版本即可。 它解决了我的问题。

答案 9 :(得分:0)

这对我有用,

rm -rf ./**/node_modules

虽然我需要lerna bootstrap

答案 10 :(得分:0)

如果您的应用程序在npm上运行,则可能需要先停止它,然后再添加或安装任何内容。 我有几次这个问题。我在EXPO CLI上运行我的React Native应用程序。关闭expo cli和chrome后,我的问题解决了。

答案 11 :(得分:0)

实际上,您正在安装的当前软件包具有某些依赖关系,而在我的npm中找不到。因此,在安装此软件包之前,只需执行以下命令。 (它将安装package.json文件中提到的所有列出的依赖项,这些依赖项是运行应用程序所必需的)

npm install 

有效...!

答案 12 :(得分:0)

第二行可能会暗示正在发生的事情:

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: Error: EPERM: operation not permitted, rename 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\fsevents-e80c4ef4\node_modules\are-we-there-yet' -> 'C:\Users\MiguelFrias\Desktop\Therabytes\node_modules\.staging\are-we-there-yet-5db4c798'

看起来npm对您尝试使用的文件夹没有足够的权限。

您可以尝试:

  • 再次删除npm_modules。
  • 使用管理员权限打开您使用的npm install编辑器/终端。

答案 13 :(得分:0)

对我来说,没有创建package-lock.json并且脚本本身之前也失败了。

这解决了我的问题:

- deleted my node_modules.
- npm cache clean 
- opened cmd as administrator at the repository folder
- logged-in to the https://registry.npmjs.org/ using username and passoward as few of my components needed authentication to install.
- npm i

答案 14 :(得分:0)

我刚刚尝试跑步

npm install 

成功了

答案 15 :(得分:0)

删除package-lock.json或node_modules&运行后:

npm install -g npm

它再次为我工作。

答案 16 :(得分:0)

要不每次都删除package-lock.json或node_modules,只需添加内容为“ package-lock = false”的文件“ .npmrc”,如果文件“ .npmrc”已经存在,则添加此字符串。

答案 17 :(得分:0)

我找到了问题的解决方案,显然是最后一个版本的npm有点问题,我使用的是npm version 5.6.0,我降级为npm version 5.3.0。毕竟这确实有效,在安装了几个包之后我仍然会得到同样的错误。

确定更改版本的npm为最后version 5.8.0现在所有工作都很完美,之前是某种原子的问题,否定了构建过程安装包依赖关系的权限。

相关问题