【问题标题】:Cordova installation error: path issue (?) - error code ENOENTCordova 安装错误:路径问题 (?) - 错误代码 ENOENT
【发布时间】:2016-05-13 10:33:41
【问题描述】:

在安装 Xcode 和 NodeJS 之后,我现在正在尝试安装 Cordova,但我收到以下关于缺少文件的错误(路径错误?)。

Luciens-MacBook-Pro:~ lucientavano$ npm cache clean
Luciens-MacBook-Pro:~ lucientavano$ sudo npm install -g cordova
Password:
npm WARN deprecated npmconf@2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
/usr/local/lib
└── (empty)

npm ERR! Darwin 15.3.0
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "install" "-g" "cordova"
npm ERR! node v4.2.6
npm ERR! npm  v3.6.0
npm ERR! path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920
npm ERR! code ENOENT
npm ERR! errno -2
npm ERR! syscall rename

npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
npm ERR! enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
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/lucientavano/npm-debug.log
npm ERR! code 1
Luciens-MacBook-Pro:~ lucientavano$ tail -10 /Users/lucientavano/npm-debug.log
21365 error npm  v3.6.0
21366 error path /usr/local/lib/node_modules/.staging/abbrev-ef9cc920
21367 error code ENOENT
21368 error errno -2
21369 error syscall rename
21370 error enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
21371 error enoent ENOENT: no such file or directory, rename '/usr/local/lib/node_modules/.staging/abbrev-ef9cc920' -> '/usr/local/lib/node_modules/cordova/node_modules/npm/node_modules/abbrev'
21371 error enoent This is most likely not a problem with npm itself
21371 error enoent and is related to npm not being able to find a file.
21372 verbose exit [ -2, true ]

您遇到过类似的问题吗?提前感谢您提出的任何建议。

【问题讨论】:

    标签: node.js macos cordova npm ionic-framework


    【解决方案1】:

    卸载cordova然后安装它对我有用。

    cd /usr/local/lib/node_modules/
    sudo npm uninstall -g cordova
    sudo npm install -g cordova
    

    【讨论】:

    • 在尝试了 6 个小时但没有任何运气后,您的解决方案就像一个魅力 - 谢谢谢谢 :)
    • 虽然原因仍然未知
    • 是的,我也可以确认卸载并再次安装就可以了
    • 也为我工作:)
    【解决方案2】:

    使用 YARN 解决它

    sudo npm install -g yarn
    yarn install -g cordova
    

    【讨论】:

      【解决方案3】:

      我曾经在使用其他软件包时遇到过同样的问题。我不得不从这里https://nodejs.org/en/download/ 重新安装节点。对我来说,当我尝试在没有 sudo 的情况下全局安装包时,或者当我使用 ctrc+c 取消某些安装包安装过程时,就会发生这种情况。之后没有办法修复它,只能重新安装节点。我也在使用 mac,现在非常小心地让 npm 完成它的工作......

      【讨论】:

      • 谢谢,最初我从 nodejs.org 安装了 Node。所以我卸载它并用brew重新安装它。然后它终于可以正常工作了,我可以安装 Cordova。
      • 在Windows上也遇到过类似的问题,重新安装node.js也解决了。
      【解决方案4】:

      在安装最新的 Apache Cordova(版本 6.0.0)时,我在 Fedora Core 22 上也发现了这个问题,当使用 sudo npm install -g cordova 安装时,问题可能会丢失有关权限检查的内容。

      npm ERR! enoent ENOENT, rename '/lib/node_modules/.staging/abbrev-cxxxxxx'
      

      npm ERR! enoent ENOENT, rename '/lib/node_modules/.staging/abbrev-xxxxxxx'

      所以以 root 身份运行 (sudo -s) 解决这个问题,然后再次运行 npm install -g cordova,问题就会解决。 (在我的环境中)。

      对于我的环境(Fedora core 22)它不需要从 nodejs.org 重新安装节点

      【讨论】:

        【解决方案5】:

        首先卸载cordova: npm uninstall -g cordova 重新安装科尔多瓦 npm install -g cordova

        【讨论】:

        • 这与其他答案有何不同?
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2013-08-02
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多