phonegap platform add ios - "Unexpected token =>" error - ios

I have a Phonegap app and need to build it in a Mac. Everything works in a machine and I'm trying to configure a new one, but on this, when I run phonegap platform add ios I receive the following error:
$ phonegap platform add ios
/usr/local/lib/node_modules/phonegap/lib/phonegap/util/connect-proxy.js:21
fs.readFile(settings, (err, data) => {
^^
SyntaxError: Unexpected token =>
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Object.Module._extensions..js (module.js:478:10)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/lib/phonegap/serve.js:9:23)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Both Macs are running with node v0.12.7 and npm 2.11.3.

Apparently phonegap is using ECMAScript 6 Features like Arrow Functions.
I think this is resulting into your error, because you are still using Node v0.12.7, which does not support these features. Installing the latest LTS version from Official Node.js should fixed that.
For further information please have a look at the phonegap requirements.

Please update your node and npm version to solved your problem.

Related

Electron w/ TensorflowJS--looking for napi-v4 but only napi-v5 present

package.json has
"#tensorflow/tfjs-node": "^1.4.0",
Here's the error:
Error: Cannot find module 'C:\Users\me\projects\myproject-desktop\project\node_modules\#tensorflow\tfjs-node\lib\napi-v4\tfjs_binding.node'
Require stack:
- C:\Users\me\projects\myproject-desktop\project\node_modules\#tensorflow\tfjs-node\dist\index.js
- C:\Users\me\projects\myproject-desktop\project\dist_electron\index.js
- C:\Users\me\projects\myproject-desktop\project\node_modules\electron\dist\resources\default_app.asar\main.js
-
at Module._resolveFilename (internal/modules/cjs/loader.js:717:15)
at Function../lib/common/reset-search-paths.ts.Module._resolveFilename (electron/js2c/browser_init.js:7609:16)
at Module._load (internal/modules/cjs/loader.js:622:27)
at Module._load (electron/js2c/asar.js:717:26)
at Function.Module._load (electron/js2c/asar.js:717:26)
at Module.require (internal/modules/cjs/loader.js:775:19)
at require (internal/modules/cjs/helpers.js:68:18)
at Object.<anonymous> (C:\Users\me\projects\myproject-desktop\project\node_modules\#tensorflow\tfjs-node\dist\index.js:44:16)
at Module._compile (internal/modules/cjs/loader.js:880:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:892:10)
If I go into C:\Users\me\projects\myproject-desktop\project\node_modules\#tensorflow\tfjs-node\lib\ there is a napi-v5\tfjs_binding.node but no napi-v4\tfjs_binding.node.
Do I just need to downgrade tensorflowjs? Anyone know what napi-v4 vs v5 is?
Yes you will need to downgrade tensorflowjs (while waiting for the next release).
The solution would be to use node 10.16.3 and run the command:
npm rebuild #tensorflow/tfjs-node --build-from-source

Lighthouse CLI - site with authentication

I'm trying to perform audit using Lighthouse CLI. My site requires authentication. How can I get Lighthouse CLI to analyse my site? Can I supply login credentials?
Also the CLI seems to be broken and/or not comply to documentation.
$ npm install -g lighthouse
$ lighthouse --help
C:\Users\kermit\AppData\Roaming\nvm\v8.11.1\node_modules\lighthouse\lighthouse-core\lib\url-shim.js:36
class URLShim extends URL {
^
ReferenceError: URL is not defined
at Object.<anonymous> (C:\Users\kermit\AppData\Roaming\nvm\v8.11.1\node_modules\lighthouse\lighthouse-core\lib\url-shim.js:36:23)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Module.require (module.js:596:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\kazuy\AppData\Roaming\nvm\v8.11.1\node_modules\lighthouse\lighthouse-core\lib\network-request.js:14:13)
at Module._compile (module.js:652:30)
Make sure you're using Node >= 10. URL got added at Node v10 (https://nodejs.org/api/globals.html#globals_url)
Please Upgrade Node and apply single or double quote on URL like below with L-CLI
lighthouse 'https://google.com' --port=9222
For the authenticated page, you have two below options
1. use --extra-headers={cookies}
2. use --port=9222 //port is debug port

async function run() { ^^^^^^^^ SyntaxError: Unexpected token function

After upgrading my react native app to version 0.59.8 i made it work on android but when trying to build it and run in on ios it shows me this error :
node_modules/react-native/node_modules/#react-native-community/cli/build/cliEntry.js:168
async function run() {
^^^^^^^^
SyntaxError: Unexpected token function
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:542:28)
at Object.Module._extensions..js (module.js:579:10)
at Module.load (module.js:487:32)
at tryModuleLoad (module.js:446:12)
at Function.Module._load (module.js:438:3)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous>
Even when doing react-native info or react-native start or react-native run-ios , it shows the same error ,
Do you Know please what does it mean this error ?
Async functions are not supported in your version of Node. You really only have two options.
To install Babel, to compile the javascript in a way that can be understood (transpiled)
Upgrade your version of Node
I would HIGHLY recommend to upgrade Node.
How to upgrade node:
https://www.surrealcms.com/blog/how-to-upgrade-or-downgrade-nodejs-using-npm.html
EDIT
I've just come across this SO post from #Quentin - which explains this better. (Kudos) so, I thought I'd include
SyntaxError: Unexpected token function - Async Await Nodejs

Update cordova project from 3.3 to 4.x

I'm having a lot of trouble updating a cordova project from 3.3 to 4.x. The documentation says that after updating de CLI I should execute:
cordova platform update iOS
But I get this error:
Error: Cannot find module 'shelljs'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/Users/danielrvt/.cordova/lib/npm_cache/cordova-ios/3.7.0/package/bin/update:21:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Function.Module.runMain (module.js:497:10)
Error: /Users/danielrvt/.cordova/lib/npm_cache/cordova-ios/3.7.0/package/bin/update: Command failed with exit code 8
at ChildProcess.whenDone (/Users/danielrvt/.nvm/v0.10.33/lib/node_modules/cordova/node_modules/cordova-lib/src/cordova/superspawn.js:135:23)
at ChildProcess.emit (events.js:98:17)
at maybeClose (child_process.js:756:16)
Can you help me with this update?
I had the same issue. Found solution here: https://issues.apache.org/jira/browse/CB-8036
install shelljs
cd
cd .cordova/lib/npm_cache/cordova-ios/3.7.0/package/bin
npm install shelljs
cordova plaform update ios
That worked for me
I had a similar problem. Try running the command with admin permissions (sudo).
sudo phonegap platform update ios
Then enter your password.

iOS push notifications using Node.js

I am writing the Node server code for sending push notifications to an iOS device. when I run my code, it produces the error below. Has anyone seen this before or know how to handle it? If it helps give some context, I am using the 'apagent' node module. Thank you!
crypto.js:145
c.context.loadPKCS12(pfx);
^
Error: Unable to load BIO
at Object.exports.createCredentials (crypto.js:145:17)
at Object.exports.connect (tls.js:1320:27)
at Agent.connect (/Projects/api/node_modules/apnagent/lib/apnagent/agent/live.js:113:17)
at Object.<anonymous> (/Projects/api/agent/_header.js:16:7)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)

Resources