如何在Cordova插件挂钩中安装Node.js库

时间:2018-08-14 06:06:52

标签: cordova ionic-framework cordova-plugins

我正在开发Cordova插件,我想在安装插件后运行一些脚本。所以我在Python 3.6.6 |Anaconda, Inc.| (default, Jun 28 2018, 17:14:51) [GCC 7.2.0] on linux Type "help", "copyright", "credits" or "license" for more information. >>> import tensorflow as tf >>> hello = tf.constant('Hello, TensorFlow!') >>> sess = tf.Session() 2018-08-14 14:35:53.739970: I tensorflow/core/platform/cpu_feature_guard.cc:141] Your CPU supports instructions that this TensorFlow binary was not compiled to use: AVX2 FMA 2018-08-14 14:35:53.948699: I tensorflow/stream_executor/cuda/cuda_gpu_executor.cc:897] successful NUMA node read from SysFS had negative value (-1), but there must be at least one NUMA node, so returning NUMA node zero 2018-08-14 14:35:53.949210: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1405] Found device 0 with properties: name: Tesla K80 major: 3 minor: 7 memoryClockRate(GHz): 0.8755 pciBusID: 0000:00:05.0 totalMemory: 11.17GiB freeMemory: 11.11GiB 2018-08-14 14:35:53.949241: I tensorflow/core/common_runtime/gpu/gpu_device.cc:1484] Adding visible gpu devices: 0 2018-08-14 14:35:53.949419: E tensorflow/core/common_runtime/direct_session.cc:158] Internal: cudaGetDevice() failed. Status: CUDA driver version is insufficient for CUDA runtime version Traceback (most recent call last): File "<stdin>", line 1, in <module> File "/usr/local/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 1494, in __init__ super(Session, self).__init__(target, graph, config=config) File "/usr/local/anaconda3/envs/tensorflow/lib/python3.6/site-packages/tensorflow/python/client/session.py", line 626, in __init__ self._session = tf_session.TF_NewSession(self._graph._c_graph, opts) tensorflow.python.framework.errors_impl.InternalError: Failed to create session. 中有<hook type="after_plugin_install" src="scripts/afterInstall.js" />

plugin.xml取决于其他一些节点库,如何确保在执行脚本之前可以自动安装这些库?我应该把afterInstall.js放在哪里?

1 个答案:

答案 0 :(得分:0)

在任何时候都没有从package.json安装插件依赖项或devDependencies。

  • 如果您的插件需要javascript依赖项,则可以将其与webpack或类似程序打包在一起,然后通过Julia language version 1.0.0 i is 1 i is 2 global i is 666 j is 1 j is 2 global j is 666 内的js-module指令添加它们。
  • 如果您需要在挂钩内添加javascript依赖项,则基本上可以执行相同的操作。通过webpack打包依赖关系,并将其放入config.xml文件夹中的js文件中。在您的钩子(scripts中,您可以执行一个相对需求(例如require('./ dependencies.js')。

我还没有找到一个示例项目,该项目需要在挂钩内具有依赖关系。也许您可以将此步骤推迟到插件的构建时间。