【问题标题】:babel-preset-es2016 requires a peer of babel-runtime but none was installedbabel-preset-es2016 需要 babel-runtime 的对等点,但没有安装
【发布时间】:2016-03-27 02:41:32
【问题描述】:

我意识到 npm 不再安装对等依赖项了,但是当我手动安装时,为什么我仍然收到警告?

    ➜  npm install babel-runtime -g     
    /usr/local/lib
    └─┬ babel-runtime@6.6.1 
      └── core-js@2.2.1 

    ➜  npm install babel-preset-es2016 -g
    /usr/local/lib
    ├── babel-preset-es2016@6.0.8 
    └── UNMET PEER DEPENDENCY babel-runtime@^6.6.1

npm WARN babel-preset-es2016@6.0.8 requires a peer of babel-runtime@^6.6.1 but none was installed.

编辑

如果我在本地安装(根据下面的建议),我不会收到警告:

➜  test npm i babel-runtime@\^6.6.1
test@1.0.0 /home/jdifool/work/test
├── babel-preset-es2016@6.0.8 
├── babel-runtime@6.6.1 
└─┬ babelify@7.2.0
  └─┬ babel-core@6.7.4
    ├─┬ babel-code-frame@6.7.4
    │ └── babel-runtime@5.8.38 
    ├─┬ babel-generator@6.7.2
    │ └── babel-runtime@5.8.38 
    ├─┬ babel-helpers@6.6.0
    │ └── babel-runtime@5.8.38 
    ├─┬ babel-messages@6.7.2
    │ └── babel-runtime@5.8.38 
    ├─┬ babel-register@6.7.2
    │ └─┬ babel-runtime@5.8.38 
    │   └── core-js@1.2.6 
    ├── babel-runtime@5.8.38 
    ├─┬ babel-template@6.7.0
    │ └── babel-runtime@5.8.38 
    ├─┬ babel-traverse@6.7.4
    │ └── babel-runtime@5.8.38 
    ├─┬ babel-types@6.7.2
    │ └── babel-runtime@5.8.38 
    └─┬ babylon@6.7.0
      └── babel-runtime@5.8.38 

为什么?

【问题讨论】:

    标签: javascript node.js npm babeljs


    【解决方案1】:

    这很冗长。只需安装所需的软件包

    $ npm i babel-runtime@^6.6.1 -g
    

    在全局范围内安装,因为您的预设也在全局范围内,然后重试。

    更新(作者@JohnDifool): 似乎警告仅针对全局安装显示。

    【讨论】:

    • 插入符号无法使用(npm i babel-runtime@^6.6.1 -g zsh: no match found: babel-runtime@^6.6.1)并且我已经安装了 babel-runtime @6.6.1
    • 我的错:我需要在 zsh 上使用 \^ 来逃脱。仍然没有运气,因为npm i babel-runtime@^6.6.1 -g 顽固地安装 6.6.1(最新?)。我的 npm 版本是 3.8.3。
    • 你能尝试安装这个包babel-core,就像npm i babel-core -g建议:为什么不把所有东西都移到一个独立的文件夹中?
    • babel-core@6.7.4 已经被 babel-cli@6.6.5 & babel-preset-es2016@6.0.8 安装了。我可以安装在一个隔离的文件夹中,但如果问题发生在全局范围内,它可能在本地是相同的。
    • 我用类似的设置运行了 3 个项目,它们运行良好!
    【解决方案2】:

    当我遇到这个问题时,通过更新 npm,清除 npm 缓存,然后再次运行 npm install 命令解决了它。但是,在此过程中存在一些问题,我将详细说明。

    更新 npm

    首先,我尝试使用 npm update -g npm 更新 npm,但出现错误:

    npm ERR! addLocal Could not install /private/var/folders/_n/vgvdlrpj64l_g98d_dxs5pd40000gp/T/npm.80873/package
    

    我能够通过使用命令npm install -g npm@latest 而不是as suggested by GitHub user bronzeiii 成功更新。

    重新运行前清理npm install

    rm -rf node_modules
    npm cache clean
    

    最后一步

    npm install

    【讨论】:

      猜你喜欢
      • 2017-04-09
      • 2018-10-26
      • 2019-06-06
      • 1970-01-01
      • 1970-01-01
      • 2016-09-12
      • 2018-03-26
      • 1970-01-01
      • 2020-10-13
      相关资源
      最近更新 更多