Ubuntu Phonegap Error while creating app - node.js

/usr/local/lib/node_modules/phonegap/lib/phonegap/util/connect-proxy.js:21
fs.readFile(settings, (err, data) => { ^SyntaxError: Unexpected token >
at Module._compile (module.js:439:25)
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)
at Object.<anonymous> (/usr/local/lib/node_modules/phonegap/lib/phonegap/serve.js:9:23)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

It means that the version of Node that you're sing doesn't support the arrow function syntax.
Which is strange because it must be 0.12 or older - which is not maintained any more and should be upgraded. The current version is 7.5.0, the latest LTS version is 6.9.5 (as of February 2017). Versions older than 4.x should not be used for anything.
For more info see:
https://developer.mozilla.org/en/docs/Web/JavaScript/Reference/Functions/Arrow_functions
For Node versions compatibility with arrow function syntax see:
http://node.green/#arrow-functions
For Node versions support schedule see:
https://github.com/nodejs/LTS#lts-schedule

Related

Different Node version Global installation

How can i install two different node version
in this case version 0.10.32 and 8.9.4 (LTS)
when i try using n or nvm to install different version of node and
then used the following command
npm list
i am getting the following error after changing to lower version i.e 0.10.32
/usr/local/lib/node_modules/npm/node_modules/npm-registry-
client/node_modules/npm-package-arg/npa.js:6
let url
^^^
SyntaxError: Unexpected strict mode reserved word
at Module._compile (module.js:439:25)
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)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-
registry-client/lib/access.js:5:11)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)

Error with node site.js

I have problem with log4js.
Problem is that when i ran node.sj error pops up:
Error: Cannot find module 'log4js'
at Function.Module._resolveFilename (module.js:336:15)
at Function.Module._load (module.js:278:25)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/bot/site.js:2:14)
at Module._compile (module.js:460:26)
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 Function.Module.runMain (module.js:501:10)
So i instaled log4js with:
npm install log4js
And now the real error is here:
/home/bot/node_modules/log4js/lib/log4js.js:25
const debug = require('debug')('log4js:main');
^^^^^
SyntaxError: Use of const in strict mode.
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> (/home/bot/site.js:2:14)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Maybe i have broken bot. But bot should be OK.
I had this error in past but i fixed it and do not know how. (about 2years ago?) and error was in bot folder i think.
i have Debian 7 installed on server
Thx for response.
which version of node.js are you running?
node --version
First of all try to install your application packages with npm install log4j --save (to save it in your package.json).
It seems that you are using an old version of node.js!
Using this site you can see when the keyword const was introduced without requiring the strict keyword!
http://node.green/#ES2015-bindings-const
To fix the error just need to update your node.js to the latest stable version.
Another solutions: (The previous one is my favourite).
You can set a single specific file to be strict by writing 'use strict' on top of your file.
Or you can force to run your whole application to strict by using node --use_strict index.js (I wont recommend this one)

Error in angular2 cli installation

I am installing angular2 in linux with
sudo npm install -g #angular/cli
and after running that it successifully installs but after typing
ng new mynewapp
Am getting an error
/usr/local/lib/node_modules/#angular/cli/models/config/config.js:16
constructor(_configPath, schema, configJson, fallbacks = []) {
^
SyntaxError: Unexpected token =
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/local/lib/node_modules/#angular/cli/models/config.js:3:18)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
what could be wrong
It's seem your nodejs version does not support ES2015, update your node to version 6+
you can using nvm to manage your node version
Your need Node version 6.x or higher
See documentation below
take a look here: https://github.com/angular/angular-cli/issues/4604

npmlog accessing superCtor.prototype

Recently, I've seen travis builds fail if they use node 0.8, like this one here. The report reads something like this:
$ npm install
util.js:538
ctor.prototype = Object.create(superCtor.prototype, {
^
TypeError: Cannot read property 'prototype' of undefined
at Object.exports.inherits (util.js:538:43)
at Object.<anonymous> (/home/travis/.nvm/v0.8.28/lib/node_modules/npm/node_modules/npmlog/node_modules/are-we-there-yet/index.js:115:6)
at Module._compile (module.js:449:26)
at Object.Module._extensions..js (module.js:467:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:362:17)
at require (module.js:378:17)
at Object.<anonymous> (/home/travis/.nvm/v0.8.28/lib/node_modules/npm/node_modules/npmlog/log.js:2:16)
at Module._compile (module.js:449:26)
Could it be that the npmlog module installed here is incompatible with node 0.8? Is there anything a project should do to fix this, is this a Travis bug to be reported somewhere, or has travis simply terminated support for node 0.8 even though it's still listed?

'The specified module could not be found' error when using 'scrypt' module in node.js

I'm trying to use 'scrypt' module. The problem is that when I try to run my nodejs application (node app.js), I get this error:
C:\Users\A\Documents\B\C>node app.js
module.js:356
Module._extensions[extension](this, filename);
^
Error: The specified module could not be found.
C:\Users\A\Documents\B\C\node_modules\scrypt\build\Release\scry
pt.node
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)
at Object.<anonymous> (C:\Users\A\Documents\B\C\node_module
s\scrypt\index.js:1:76)
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)
I installed 'scrypt' module with this line:
npm install scrypt -msvs_version=2012
the -msvs_version is taken from this answer
You should have a look at this node-scrypt issue.
According to what is said there, you should be able to solve your problem by
either installing OpenSSL for Windows
or installing and building with Visual Studio 2010

Resources