簡體   English   中英

babel-preset-es2016需要babel-runtime的同位體,但未安裝

[英]babel-preset-es2016 requires a peer of babel-runtime but none was installed

我意識到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 

為什么?

這很冗長。 只需安裝所需的軟件包

$ npm i babel-runtime@^6.6.1 -g

因為您的預設也在全局范圍內,所以請在全局范圍內安裝,然后重試。

更新 (通過@JohnDifool進行):似乎僅針對全局安裝顯示警告。

當我遇到此問題時,可以通過更新npm,清除npm緩存,然后再次運行npm install命令來解決。 但是,正如我將詳細說明的那樣,在此過程中存在一些問題。

更新npm

首先,我嘗試使用npm update -g npm ,但這引發了錯誤:

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

我可以使用命令npm install -g npm@latest來成功更新, 如GitHub用戶bronziii所建議

在重新運行npm install之前進行清理

rm -rf node_modules
npm cache clean

最后一步

npm install

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM