尝试创建Ubuntu快照时OPC UA客户端出现问题

时间:2020-07-27 05:22:03

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

我已经使用OPC UA软件包创建了一个可运行的应用程序。我在Linux VM(Ubuntu 18.04 Bionic)上运行了它,并希望将其放入快照中以便在其他系统上更轻松地重用。我在他们的文档中遵循了有关如何创建Node.js快照的教程。但是在执行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的最新版本 有人认识到这个问题吗?或者有人可以在这里帮我吗?

2 个答案:

答案 0 :(得分:0)

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

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

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

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

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

答案 1 :(得分:0)