如何将 Nodejs 包添加到 Yocto?

发布于 2025-01-10 23:45:36 字数 198 浏览 0 评论 0原文

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

I would like to have an OS which support nodejs. In my yocto project at layer.conf file I add
IMAGE_INSTALL_append = " nodejs"
IMAGE_INSTALL_append = " nodejs-npm"
which result in to have an OS with nodejs support afer bake. Now I want to add some NPM packages also like basic-auth etc.
would you please help me.
kind regards.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

在你怀里撒娇 2025-01-17 23:45:36

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

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

使用 devtool 创建配方:

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

您也可以设置特定版本。

配方如下:

  • basic-auth_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 处理的更多信息,请检查此 链接

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

编辑

如果遇到错误:

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

只需将 name 更改为 package

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

In order to add an npm package into your image, you need to create a recipe for it.

Yocto has an npm source scheme handler, and you can use registry.npmjs.org to create a recipe fetching your wanted package.

Create a recipe with devtool:

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

You can set a specific version as well.

The recipe would be the following:

  • basic-auth_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"

It compiles correctly.

You can move it to your custom layer after testing it with devtool:

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

For more information about npm handling check this link

I encourage you to read more about Yocto NPM handling in their official documentation in this link

EDIT:

If you encounter the error:

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

just change name to package :

devtool add "npm://registry.npmjs.org;package=basic-auth;version=latest"
二智少女 2025-01-17 23:45:36

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

这里有第三方库

如果页面上没有找到该包,需要自己编译使用适合您平台的编译器并按配方手动添加。

You can add any package which is available by Openembedded Layer in your Yocto release. Please look to Openembedded Layer to find the package you want. After that, you can add any package via your local.conf file.

Here is a third party library

If you don't find the package on the page, you need to compile it on your own using a compiler for your platform and add it manually by recipe.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文