【问题标题】:npm: ENOENT: no such file or directorynpm: ENOENT: 没有这样的文件或目录
【发布时间】:2015-11-10 22:22:44
【问题描述】:

我正在使用npm3.3.6,当我尝试安装一堆模块时,我收到以下错误:

npm i babel-cli babel-plugin-syntax-async-functions babel-plugin-transform-regenerator babel-polyfill babel-preset-es2015 babelify watchify browserify --save-dev

npm ERR! Darwin 15.0.0
npm ERR! argv "/Users/thomas/.nvm/versions/node/v5.0.0/bin/node" "/Users/thomas/.nvm/versions/node/v5.0.0/bin/npm" "i" "babel-cli" "babel-plugin-syntax-async-functions" "babel-plugin-transform-regenerator" "babel-polyfill" "babel-preset-es2015" "babelify" "watchify" "browserify" "--save-dev"
npm ERR! node v5.0.0
npm ERR! npm  v3.3.6
npm ERR! path /Users/thomas/Desktop/esnext-bootstrap/node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents/node_modules/asn1
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/Users/thomas/Desktop/esnext-bootstrap/node_modules/babel-cli/node_modules/chokidar/node_modules/fsevents/node_modules/asn1' -> '/Users/thomas/Desktop/esnext-bootstrap/node_modules/asn1'
npm ERR! enoent This is most likely not a problem with npm itself
npm ERR! enoent and is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/thomas/Desktop/esnext-bootstrap/npm-debug.log

我不知道这里发生了什么,也不知道具体是什么模块导致了这个问题。我可以看到它涉及babel-clichokidarans1,但是当我单独安装babel-cli 时,它可以正常工作而不会出现错误。

刚刚单独安装了每个模块,效果很好。

【问题讨论】:

  • 我刚刚运行了一个完整的测试,将每个模块分别安装和一起安装,没有发生错误。我两次都删除了node_modules 文件夹。如果有人想重新创建这里是starter repo

标签: npm rename babeljs


【解决方案1】:

我遇到了一个非常相似的问题,这是因为我试图从 Ubunutu 中安装的 HGFS 卷进行 npm 安装。

这是因为我在 OSX 上使用 VMWare Fusion 来虚拟化 Ubuntu,然后在 Ubuntu 中挂载共享的 OSX 目录。

在未挂载的目录(即我的 Ubuntu 主文件夹)中使用相同源的另一个 npm 安装按预期工作。

【讨论】:

  • 啊,好点子,在不允许符号链接的文件系统上运行会破坏构建(Windows 共享也是如此)。
【解决方案2】:

我看到了类似的问题。当 node_modules 目录存在并且您运行 npm install 时会导致该问题。有一些名称冲突。如果您删除 node_modules 目录,您将不会遇到问题。

【讨论】:

  • 如果您是全局安装,则需要删除全局副本上的 node_modules 文件夹。感谢@martin 的回答。
【解决方案3】:

当我遇到此错误时,我会在任务管理器(Windows 上的进程资源管理器)中杀死/关闭所有正在运行的节点实例。运行开放节点进程的通常是 vscode 或 webstorm。对我来说,在关闭这些程序并确保没有正在运行的节点进程之后,npm install 现在将再次运行。

【讨论】:

    猜你喜欢
    • 2018-02-15
    • 1970-01-01
    • 2018-06-29
    • 2016-11-03
    • 2018-07-03
    • 2014-01-12
    • 1970-01-01
    • 2023-03-31
    • 2019-06-24
    相关资源
    最近更新 更多