0

我想要一个支持 nodejs 的操作系统。在 layer.conf 文件的 yocto 项目中,我添加了 IMAGE_INSTALL_append = " nodejs" IMAGE_INSTALL_append = " nodejs-npm" ,这导致在烘烤后有一个支持 nodejs 的操作系统。现在我想添加一些 NPM 包,比如 basic-auth 等。请你帮帮我。亲切的问候。

4

2 回答 2

0

为了将npm包添加到您的图像中,您需要为其创建一个配方。

Yocto 有一个npm源方案处理程序,您可以使用它registry.npmjs.org来创建一个获取您想要的包的配方。

使用 devtool 创建配方:

devtool add "npm://registry.npmjs.org;name=basic-auth;version=latest"

您也可以设置特定版本。

配方如下:

  • 基本身份验证_2.0.1.bb
# Recipe created by recipetool
# This is the basis of a recipe and may need further editing in order to be fully functional.
# (Feel free to remove these comments when editing.)

SUMMARY = "node.js basic auth parser"
# WARNING: the following LICENSE and LIC_FILES_CHKSUM values are best guesses - it is
# your responsibility to verify that the values are complete and correct.
LICENSE = "MIT"
LIC_FILES_CHKSUM = "file://LICENSE;md5=42fffe6fe0b70501d52150ebb52113df \
                    file://node_modules/safe-buffer/LICENSE;md5=badd5e91c737e7ffdf10b40c1f907761"

SRC_URI = "npm://registry.npmjs.org/;name=basic-auth;version=latest"

NPM_SHRINKWRAP := "${THISDIR}/${PN}/npm-shrinkwrap.json"

inherit npm

# Must be set after inherit npm since that itself sets S
S = "${WORKDIR}/npmpkg"
LICENSE_${PN}-safe-buffer = "MIT"
LICENSE_${PN} = "MIT"

它编译正确。

您可以在使用以下命令对其进行测试后将其移动到您的自定义层devtool

devtool finish basic-auth <path/to/meta-custom> or
devtool finish basic-auth <layer/in/bblayers.conf>

有关npm处理的更多信息,请查看此链接

我鼓励您在此链接NPM的官方文档中阅读有关 Yocto处理的更多信息

编辑

如果遇到错误:

is missing the required parameter 'Parameter 'package' required'

只需更改namepackage

devtool add "npm://registry.npmjs.org;package=basic-auth;version=latest"
于 2022-02-28T10:52:50.733 回答
0

您可以在 Yocto 版本中添加 Openembedded Layer 可用的任何数据包。请查看Openembedded Layer以找到您想要的数据包。之后,您可以通过local.conf文件添加任何数据包。

这是第三方库

如果您在页面上没有找到该数据包,则需要使用适合您平台的编译器自行编译,并通过配方手动添加。

于 2022-02-28T10:10:47.390 回答