0

I've created a working app by using the OPC UA package for node. I ran it on a Linux VM (Ubuntu 18.04 Bionic) and want to put it into a snap for easier reuse on other systems. I followed the tutorial in their docs on how to create a nodejs snap. But when executing snapcraft it fails at some point and I get this error:

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.

I have the latest versions of NPM and node.js Does someone recognize that problem? Or can someone help me out here?

KorJu
  • 1
  • 3

2 Answers2

0

you need to use a more recent version of node-js.

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

node-opcua requires nodejs version 10 at least. ( current nodejs version is 14)

you need to specify the require nodejs version in your snapcraft.yml file:

...
    plugin: nodejs
    nodejs-version: "14.7.0"
...
Etienne
  • 16,249
  • 3
  • 26
  • 31
  • I have node installed. Version is 12.18. `ubuntu-doku@ubuntudoku-VirtualBox:~/Dokumente/OPC_UA_TESTING_v3/OPC_UA_TESTING$ node -v v12.18.3` – KorJu Jul 29 '20 at 04:26
  • you may have node 12 installed on ubuntu. This version will not be used by snap. Snap will use the version specifed by the snapcraft.yml file or v6 if the version is not specified. – Etienne Jul 30 '20 at 21:46
  • I've tried to specify the version in the yml file by writing nodejs-version: '14.7.0'. And i got the following error: Failed to load plugin: properties failed to load for opcproject: Additional properties are not allowed ('nodejs-yarn-version', 'nodejs-version', 'nodejs-package-manager' were unexpected) – KorJu Jul 31 '20 at 07:26
0

that's the link to the npm-debug.log file.

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

KorJu
  • 1
  • 3