npm 的“跳过失败的可选依赖项”是啥意思?
Posted
技术标签:
【中文标题】npm 的“跳过失败的可选依赖项”是啥意思?【英文标题】:What does npm mean by 'Skipping failed optional dependency'?npm 的“跳过失败的可选依赖项”是什么意思? 【发布时间】:2016-06-09 06:06:59 【问题描述】:最新版本的 node 和 npm 导致运行 karma 出现问题。当我尝试安装 karma-cli npm i -g karma karma-cli
时,我收到以下警告:
npm WARN optional Skipping failed optional dependency /chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@1.0.8
npm WARN optional Skipping failed optional dependency /gulp-karma/chokidar/fsevents:
npm WARN notsup Not compatible with your operating system or architecture: fsevents@0.2.1
当我尝试运行 karma test
时,出现以下错误:
"C:\Program Files\nodejs\node.exe" "C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js" --karmaPackageDir=C:\Users\xxx\AppData\Roaming\npm\node_modules\karma --configFile=C:\Users\xxx\Documents\project\karma.conf.js
26 02 2016 11:24:07.871:WARN [plugin]: Cannot find plugin "karma-chrome-launcher".
Did you forget to install it ?
npm install karma-chrome-launcher --save-dev
26 02 2016 11:24:07.877:WARN [plugin]: Cannot find plugin "karma-firefox-launcher".
Did you forget to install it ?
npm install karma-firefox-launcher --save-dev
26 02 2016 11:24:07.878:WARN [plugin]: Cannot find plugin "karma-phantomjs-launcher".
Did you forget to install it ?
npm install karma-phantomjs-launcher --save-dev
26 02 2016 11:24:07.879:WARN [plugin]: Cannot find plugin "karma-jasmine".
Did you forget to install it ?
npm install karma-jasmine --save-dev
26 02 2016 11:24:07.880:WARN [plugin]: Cannot find plugin "karma-junit-reporter".
Did you forget to install it ?
npm install karma-junit-reporter --save-dev
26 02 2016 11:24:07.885:WARN [plugin]: Cannot find plugin "karma-teamcity-reporter".
Did you forget to install it ?
npm install karma-teamcity-reporter --save-dev
26 02 2016 11:24:07.887:WARN [plugin]: Cannot find plugin "karma-coverage".
Did you forget to install it ?
npm install karma-coverage --save-dev
26 02 2016 11:24:07.888:WARN [plugin]: Cannot find plugin "karma-jasmine-html-reporter".
Did you forget to install it ?
npm install karma-jasmine-html-reporter --save-dev
26 02 2016 11:24:07.889:WARN [plugin]: Cannot find plugin "karma-ng-html2js-preprocessor".
Did you forget to install it ?
npm install karma-ng-html2js-preprocessor --save-dev
26 02 2016 11:24:07.890:WARN [plugin]: Cannot find plugin "karma-browserify".
Did you forget to install it ?
npm install karma-browserify --save-dev
26 02 2016 11:24:07.893:WARN [preprocess]: Can not load "coverage", it is not registered!
Perhaps you are missing some plugin?
26 02 2016 11:24:07.893:WARN [preprocess]: Can not load "ng-html2js", it is not registered!
Perhaps you are missing some plugin?
26 02 2016 11:24:07.893:WARN [preprocess]: Can not load "browserify", it is not registered!
Perhaps you are missing some plugin?
26 02 2016 11:24:07.901:WARN [reporter]: Can not load "coverage", it is not registered!
Perhaps you are missing some plugin?
26 02 2016 11:24:07.901:WARN [reporter]: Can not load "junit", it is not registered!
Perhaps you are missing some plugin?
C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:9
throw error('No provider for "' + name + '"!');
^
Error: No provider for "framework:jasmine"! (Resolving: framework:jasmine)
at error (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:22:12)
at Object.parent.get (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:9:13)
at get (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:54:19)
at C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\server.js:138:20
at Array.forEach (native)
at Server._start (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\server.js:137:21)
at invoke (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\node_modules\di\lib\injector.js:75:15)
at Server.start (C:\Users\xxx\AppData\Roaming\npm\node_modules\karma\lib\server.js:102:18)
at Object.<anonymous> (C:\Program Files (x86)\JetBrains\WebStorm 11.0.3\plugins\js-karma\js_reporter\karma-intellij\lib\intellijServer.js:12:13)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
Process finished with exit code 1
我的配置规范如下:
节点版本: v4.3.0
NPM 版本: 3.7.3
我无法安装 karma 版本,我认为它没有正确安装在我的机器上。
【问题讨论】:
【参考方案1】:这不是错误。这是一个警告,fseventsd
是特定于 Mac OS 的,无法在 Linux 上安装。
无需惊慌,需要fsevents
的包仍然可以工作——这就是为什么它是一个可选依赖项。
由于很多人对此感到困惑(特别是因为这曾经是一个真正的错误,而不是警告)所以an open bug to make the current warning into an INFO instead
另外 yarn 已经这样做了。
【讨论】:
谢谢。通过将我的 nodejs 升级到最新版本,它有助于解决这个问题。我现在没有收到任何错误。但是当我运行业力测试时,我收到以下错误,如问题中所指定。但是,当我检查 node_modules 内部时,我看到: karma-chrome-launcher 已安装,如果我进去,该特定页面的 node_modules 尚未创建。因此,对于许多软件包来说,都有同样的问题。所以我手动安装它的依赖项。如果 dis 与 npm pblm 或其业力作者 pblm 有关,有什么办法可以克服。npm ls karma-chrome-launcher
带给你什么?
@mikemaccana 这是你说的 MAC OSX 特定的。当我在 vagrant 中执行 npm install
时,我收到警告(确实没有错误),但仍然没有安装 elixir,所以我不能使用 sass。当我在 vagrant 之外运行npm install
时,它会在没有警告的情况下运行,但仍然没有安装长生不老药……结论我不能使用 gulp(可能是因为 sfevents)。有什么帮助吗?
@NicolasV 在安装与操作系统无关的软件包的任何地方都会出现警告。例如,在 Linux 上安装 Windows 程序包,在 Mac OS 上安装 Linux 特定程序包等。听起来你有可能安装单独的 elixir - 最好作为不同的问题提出。
有没有办法以某种方式抑制它?它让我很困扰它时不时地弹出......以上是关于npm 的“跳过失败的可选依赖项”是啥意思?的主要内容,如果未能解决你的问题,请参考以下文章
package.json 里的 devDependencies 是啥意思
运行“npm install”时,“x 软件包正在寻找资金”是啥意思?