【问题标题】:Problem with the OPC UA Client while trying to create an Ubuntu snap尝试创建 Ubuntu 快照时 OPC UA 客户端出现问题
【发布时间】:2020-11-16 10:01:04
【问题描述】:

我已经使用适用于节点的 OPC UA 包创建了一个工作应用程序。我在 Linux 虚拟机(Ubuntu 18.04 Bionic)上运行它,并希望将其放入快照中,以便在其他系统上更轻松地重用。我按照他们的文档中关于如何创建 nodejs snap 的教程进行操作。但是在执行 snapcraft 时,它会在某些时候失败,并且出现此错误:

ubuntu-doku@ubuntudoku-VirtualBox:~/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING$ snapcraft
Pulling opcproject 
Downloading 'node-v6.14.2-linux-x64.tar.gz'[==============================] 100%
npm --cache-min=Infinity install
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm WARN opc_ua_testing@1.0.0 No repository field.
npm --cache-min=Infinity install --global

> node-opcua-client@2.8.0 postinstall /home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/install/lib/node_modules/opc_ua_testing/node_modules/node-opcua-client
> node test_helpers/create_certificates.js certificate -s -o certificates/client_selfsigned_cert_2048.pem

/home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/install/lib/node_modules/opc_ua_testing/node_modules/chalk/source/index.js:106
    ...styles,
    ^^^

SyntaxError: Unexpected token ...
    at createScript (vm.js:56:10)
    at Object.runInThisContext (vm.js:97:10)
    at Module._compile (module.js:549:28)
    at Object.Module._extensions..js (module.js:586:10)
    at Module.load (module.js:494:32)
    at tryModuleLoad (module.js:453:12)
    at Function.Module._load (module.js:445:3)
    at Module.require (module.js:504:17)
    at require (internal/module.js:20:19)
    at Object.<anonymous> (/home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/install/lib/node_modules/opc_ua_testing/node_modules/node-opcua-pki/dist/crypto_create_CA.js:32:15)
/home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/install/lib
└── (empty)

npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules/opc_ua_testing/node_modules/chokidar/node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"linux","arch":"x64"})
npm ERR! Linux 5.4.0-42-generic
npm ERR! argv "/home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/install/bin/node" "/home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/install/bin/npm" "--cache-min=Infinity" "install" "--global"
npm ERR! node v6.14.2
npm ERR! npm  v3.10.10
npm ERR! code ELIFECYCLE

npm ERR! node-opcua-client@2.8.0 postinstall: `node test_helpers/create_certificates.js certificate -s -o certificates/client_selfsigned_cert_2048.pem`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the node-opcua-client@2.8.0 postinstall script 'node test_helpers/create_certificates.js certificate -s -o certificates/client_selfsigned_cert_2048.pem'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the node-opcua-client package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node test_helpers/create_certificates.js certificate -s -o certificates/client_selfsigned_cert_2048.pem
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs node-opcua-client
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls node-opcua-client
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu-doku/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING/parts/opcproject/src/npm-debug.log
npm ERR! code 1
Failed to run 'npm --cache-min=Infinity install --global' for 'opcproject': Exited with code 1.

我有最新版本的 NPM 和 node.js 有人认识到这个问题吗?或者有人可以在这里帮助我吗?

【问题讨论】:

  • 你能澄清'他们文档中的教程'吗?你能提供一个网址,以便我们知道你指的是哪一个吗?
  • ** snapcraft 教程:snapcraft.io/docs/node-apps

标签: node.js ubuntu-18.04 snapcraft node-opcua


【解决方案1】:
【解决方案2】:

您需要使用更新版本的 node-js。

Pulling opcproject 
Downloading 'node-v6.14.2-linux-x64.tar.gz'[==============================] 100%

node-opcua 至少需要 nodejs 版本 10。 (当前nodejs版本是14)

您需要在 snapcraft.yml 文件中指定需要的 nodejs 版本:

...
    plugin: nodejs
    nodejs-version: "14.7.0"
...

【讨论】:

  • 我已经安装了节点。版本是 12.18。 ubuntu-doku@ubuntudoku-VirtualBox:~/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING$ node -v v12.18.3
  • 您可能在 ubuntu 上安装了节点 12。 snap 不会使用此版本。 Snap 将使用 snapcraft.yml 文件指定的版本,如果没有指定版本,则使用 v6。
  • 我尝试通过编写 nodejs-version: '14.7.0' 来指定 yml 文件中的版本。我收到以下错误:加载插件失败:无法为 opcproject 加载属性:不允许附加属性('nodejs-yarn-version'、'nodejs-version'、'nodejs-package-manager' 是意外的)
猜你喜欢
  • 2020-07-24
  • 2020-08-28
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 2020-03-08
相关资源
最近更新 更多