【问题标题】:NPM Global Install FailsNPM 全局安装失败
【发布时间】:2019-02-08 10:24:48
【问题描述】:

此 CLI 的全局安装开始失败,我不知道为什么。

git clone https://github.com/superflycss/cli
cd cli
npm i -g

日志文件是10K行日志,但最后是这样写的:

    7353 verbose stack Error: ENOENT: no such file or directory, rename '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@superflycss/cli-5549c074/node_modules/@babel/code-frame' -> '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@babel/code-frame-78217d7a'
    7354 verbose cwd /home/ole/SuperflyCSS/cli
    7355 verbose Linux 4.15.0-45-generic
    7356 verbose argv "/home/ole/.nvm/versions/node/v11.0.0/bin/node" "/home/ole/.nvm/versions/node/v11.0.0/bin/npm" "i" "-g"
    7357 verbose node v11.0.0
    7358 verbose npm  v6.7.0
    7359 error path /home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@superflycss/cli-5549c074/node_modules/@babel/code-frame
    7360 error code ENOENT
    7361 error errno -2
    7362 error syscall rename
    7363 error enoent ENOENT: no such file or directory, rename '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@superflycss/cli-5549c074/node_modules/@babel/code-frame' -> '/home/ole/.nvm/versions/node/v11.0.0/lib/node_modules/.staging/@babel/code-frame-78217d7a'
    7364 error enoent This is related to npm not being able to find a file.
    7365 verbose exit [ -2, true ]

I've tried removing all global modules per the instructions here 然后重新安装。但是,即使完全刷新本地模块,它仍然会失败 (Nuke local node_modules)。

也试过了:

sudo rm -fr /home/ole/.npm-packages/*

然后npm i -g,结果还是一样。

更新

我认为可能是这个错误:

https://npm.community/t/global-installs-sudo-npm-i-g-fail-on-mac-after-6-5-upgrade-works-fine-after-6-4-1-downgrade/4082/15

【问题讨论】:

  • 你用的NPM是什么版本的?
  • 您是否有理由要全局安装 package.json 中的所有内容?好像有点奇怪……
  • 我是 CLI 的开发人员。我有 Jest 单元测试,但有时我会执行本地全局安装以便手动进行本地测试。

标签: javascript node.js ubuntu npm


【解决方案1】:

也许您可以尝试通过 npmjs 注册表使用 npm 全局安装 superflycss CLI,而不是克隆 superflycss 存储库并尝试从源代码构建。例如:

npm i -g @superflycss/cli

然后像这样使用它:

  Usage: sfc [options] [command]

希望对您有所帮助!

【讨论】:

  • 我也这样做 - 但我是 CLI 的作者,所以我需要能够在本地安装以用于开发目的。
【解决方案2】:
docker run -it node bash
git clone https://github.com/superflycss/cli
cd cli
npm i -g

效果很好!

root@c3adb3ae08aa:/cli# sfc --version
1.0.0
root@c3adb3ae08aa:/cli# sfc --help
Usage: sfc [options] [command]

SuperflyCSS Command Line Interface
[more stuff here]

尝试清除你的 node_modules 全局缓存和本地目录。

【讨论】:

  • 我用删除全局模块的步骤更新了问题。我想知道它是否与 npm 6.7.0 版本有关......我认为这在我安装之后开始发生。它对我来说也很好用。
  • 我也在用这个(npm i -g 没有 sudo):github.com/sindresorhus/guides/blob/master/…
【解决方案3】:

通过升级到节点 v11.9.0 和 NPM v6.7.0 解决了这个问题。

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2012-11-11
    • 1970-01-01
    • 1970-01-01
    • 2017-02-04
    • 2012-12-07
    相关资源
    最近更新 更多