简体   繁体   English

npm install:检查是否安装了特定的应用程序

[英]npm install: check that specific application is installed

I'm trying to write unit tests for Angular application and right now working on describing all required packages for unit testing like karma,phantomjs etc. OS: Ubuntu 14. 我正在尝试为Angular应用程序编写单元测试,现在正在努力描述单元测试所需的所有软件包,例如karma,phantomjs等。OS:Ubuntu 14。

The thing is that Phantom.js doesn't work without "libfontconfig" installed in the system ( bug description ) And as I understand it's not possible to install it with: 事实是,如果没有在系统中安装“ libfontconfig”( 错误描述 ),Phantom.js将无法正常工作。据我所知,无法使用以下命令进行安装:

npm install --save-dev libfontconfig

How to output to user warning that certain installation is required when he tries to do: 当用户尝试执行某些安装操作时,如何向用户发出警告:

npm install

UPD UPD

I decided to provide more specific details on my case. 我决定提供有关我的案件的更多具体细节。 So, I'm going to use Karma and Phantom.js to test my application. 因此,我将使用Karma和Phantom.js来测试我的应用程序。 Here are all devDependencies of a project: 这是项目的所有devDependencies:

"devDependencies": 
{
"grunt": "~0.4.5",
"grunt-contrib-less": "~1.1.0",
"grunt-contrib-watch": "~0.6.1",
"jit-grunt": "~0.9.1",
"angular-route": "~1.4.8",
"angular": "~1.4.8",
"moment": "~2.10.6",
"jquery": "~1.11.3",
"bootstrap": "~3.3.6",
"angularjs-datepicker": "~0.2.16",
"phantomjs": "~1.9.8",
"karma": "^0.12.16",
"karma-jasmine": "~0.1.0",
"karma-phantomjs-launcher": "~0.2.3"
}

When I try to run unit test with Karma: 当我尝试使用Karma运行单元测试时:

node node_modules/karma/bin/karma start test/karma.conf.js

I receive the following error: 我收到以下错误:

ERROR [phantomjs.launcher]: /vagrant/node_modules/phantomjs/lib/phantom/bin/phantomjs: error while loading shared libraries: libfontconfig.so.1: cannot open shared object file: No such file or directory

So, my question is: 所以,我的问题是:

1) Should I check existence of this library or I can just describe it in README? 1)我应该检查该库是否存在,还是可以在README中对其进行描述?

2) If I should check, how I can do it? 2)如果我应该检查,该怎么办? Is it a good idea to use bash? 使用bash是个好主意吗? As I understand it will not work on Windows machine in this case. 据我了解,在这种情况下,它将无法在Windows计算机上运行。

You should be able to use the scripts field in your package.json 您应该能够使用package.json中的scripts字段

https://docs.npmjs.com/misc/scripts https://docs.npmjs.com/misc/scripts

Would simply need to create a nodeJS script that you would call on post-install that would do the check for libfontconfig 只需创建一个nodeJS脚本,然后在安装后调用该脚本即可检查libfontconfig

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM