You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@cordova.apache.org by "AlainReve (via GitHub)" <gi...@apache.org> on 2024/03/02 13:47:41 UTC

[D] The hello world example won't build [cordova]

GitHub user AlainReve created a discussion: The hello world example won't build

I'm trying to follow the tutorial here : 
cordova.apache.org/docs/en/latest/guide/cli/index.html

When I type : 
cordova create hello com.example.hello HelloWorld

It says :
/usr/local/lib/node_modules/cordova/node_modules/nopt/lib/nopt-lib.js:64
  const StringType = typeDefs.String?.type
                                     ^
SyntaxError: Unexpected token '.'
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/usr/local/lib/node_modules/cordova/node_modules/nopt/lib/nopt.js:1:
    at Module._compile (internal/modules/cjs/loader.js:999:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)

The file nopt-lib.js looks normal, as far as I can tell. 





GitHub link: https://github.com/apache/cordova/discussions/467

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [D] The hello world example won't build [cordova]

Posted by "AlainReve (via GitHub)" <gi...@apache.org>.
GitHub user AlainReve added a comment to the discussion: The hello world example won't build

I typed : 
sudo apt install nodejs
It said : 
nodejs is already the newest version (12.22.9~dfsg-1ubuntu3.3). 
And : 
node --version
Gave : 
v12.22.9

So I don't understand. If the latest is version 20, why does my system tell me the newest version is 12.22.9 ? (I've done the update).

GitHub link: https://github.com/apache/cordova/discussions/467#discussioncomment-8656215

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [D] The hello world example won't build [cordova]

Posted by "breautek (via GitHub)" <gi...@apache.org>.
GitHub user breautek added a comment to the discussion: The hello world example won't build

Not sure if the formatting is correct, it's likely erroring on `?.` syntax, which suggest that you're using a NodeJS version that doesn't have [optional chaining](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Operators/Optional_chaining) support.

Can you run `node -v` to confirm your NodeJS version? The recommended version today is NodeJS 20.

GitHub link: https://github.com/apache/cordova/discussions/467#discussioncomment-8652012

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org


Re: [D] The hello world example won't build [cordova]

Posted by "AlainReve (via GitHub)" <gi...@apache.org>.
GitHub user AlainReve added a comment to the discussion: The hello world example won't build

OK, the Ubuntu version was lagging behind. 

The fix was to install NVM (multiple versions of node.js)

**Ubuntu solution**  

First install curl. (NOT with "sudo snap install curl", this will cause failure later. Use "sudo apt install curl").
Then you type : 
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.1/install.sh | bash
Then you close and reopen the terminal (or type the "export" etc. listed at the bottom of the shell).

nvm --help
starts by saying "Node Version Manager (v0.39.1)
Don't worry, this is the version of nvm, not the version of node.js.

Then you type : 
nvm install node
This will install the latest version and make it default. I got node.js version 21.6.2.

Then the command : 
cordova create hello com.example.hello HelloWorld funtioned! 

Big thank you to breautek for pointing me in the right direction. It didn't cross my mind that the Ubuntu packages could be lagging behind the current version so much. I was really stuck.






GitHub link: https://github.com/apache/cordova/discussions/467#discussioncomment-8656529

----
This is an automatically sent email for issues@cordova.apache.org.
To unsubscribe, please send an email to: issues-unsubscribe@cordova.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@cordova.apache.org
For additional commands, e-mail: issues-help@cordova.apache.org