1

我使用节点的 OPC UA 包创建了一个工作应用程序。我在 Linux VM (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 有人认识到这个问题吗?或者有人可以在这里帮助我吗?

4

2 回答 2

1

这是 npm-debug.log 文件的链接。

https://docs.google.com/document/d/1lQIGYopbdACnC_fOekNEj4fkLNMxkf5QL19oUqZqr74/edit?usp=sharing

于 2020-07-30T04:47:33.500 回答
0

您需要使用更新版本的 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"
...
于 2020-07-27T07:24:24.550 回答