SyntaxError: /root/anon/config.json: Unexpected token ] - json

The full error is:
SyntaxError: /root/anon/config.json: Unexpected token ]
at Object.parse (native)
at Object.Module._extensions..json (module.js:425:27)
at Module.load (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/register.js:45:36)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at loadJson (/root/anon/anon.coffee:63:3)
at getConfig (/root/anon/anon.coffee:51:12)
at main (/root/anon/anon.coffee:136:12)
at Object.<anonymous> (/root/anon/anon.coffee:147:3)
at Object.<anonymous> (/root/anon/anon.coffee:3:1)
at Module._compile (module.js:410:26)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/coffee-script.js:173:23)
at compileScript (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:224:29)
at compilePath (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:174:14)
at Object.exports.run (/usr/local/lib/node_modules/coffee-script/lib/coffee-script/command.js:98:20)
at Object.<anonymous> (/usr/local/lib/node_modules/coffee-script/bin/coffee:7:41)
at Module._compile (module.js:410:26)
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 Function.Module.runMain (module.js:442:10)
at startup (node.js:136:18)
at node.js:966:3
The code I'm working with is:
https://pastebin.com/pVYwHpLc
(Don't worry, I changed the keys.)
I'm confused what and where the error is (front end is my thing). Any help is appreciated.
Sorry to bother.

Although a bit late answer, the error is on line 12:
"204.97.104.30",
You should delete the comma character (,) to have a valid JSON

Related

Having trouble with gulp

I have tried override in package.jason but it didn't work for me.
Using gulpfile ~\my-project\gulpfile.js
fs.js:47
} = primordials;
^
ReferenceError: primordials is not defined
at fs.js:47:5
at req_ (C:\Users\田旻瑞\my-project\node_modules\natives\index.js:143:24)
at Object.req [as require] (C:\Users\田旻瑞\my-project\node_modules\natives\index.js:55:10)
at Object.<anonymous> (C:\Users\田旻瑞\my-project\node_modules\vinyl-fs\node_modules\graceful-fs\fs.js:1:37)
at Module._compile (node:internal/modules/cjs/loader:1103:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1155:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)```

SyntaxError: Unexpected number when reading CSV

I'm trying to read CSV with Javascript, but I'm getting an error.
Here is my code:
fs.readFile('./data/AMZN.csv', async (err,data)=>{
if(err){
console.log(err)
return
}
console.log(data.replace("$",""));
})
Here is the example of my CSV data:
Date, Close/Last, Volume, Open, High, Low
09/11/2020, $3116.22, 5093982, $3208.69, $3217.3409, $3083.98
09/10/2020, $3175.11, 5330741, $3307.219, $3349.89, $3170.55
09/09/2020, $3268.61, 5188675, $3202.99, $3303.175, $3185
And here is the error that I get:
SyntaxError: Unexpected number
at wrapSafe (internal/modules/cjs/loader.js:1072:16)
at Module._compile (internal/modules/cjs/loader.js:1122:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
at Module.load (internal/modules/cjs/loader.js:1002:32)
at Function.Module._load (internal/modules/cjs/loader.js:901:14)
at Module.require (internal/modules/cjs/loader.js:1044:19)
at require (internal/modules/cjs/helpers.js:77:18)
at Object.<anonymous> (C:\Users\jackl\Desktop\Projects\scraper_cheerio\scraper.js:5:14)
at Module._compile (internal/modules/cjs/loader.js:1158:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1178:10)
I've figured out that Javascript perceives $3116 as a string and the following .22 as a property of that string object, which can not be a number and therefore throws "Unexpected number".
But how do I fix it? I've been trying to deal with it for 2 days, but no luck so far.
The problem was in this line:
const AMZN = require("./data/AMZN.csv");
The code in the question works fine.

Sequelize model error-tring to make model in sequelize and getting this error

Error 471--cannot find module!
This is the model I am tring to write.T
have data is already in mysql. Tring to connect from sequilize. I deleted all node module and tried again,nothing is working.Please suggest something.
module.exports = function(sequelize,dataTypes) {
var calender = sequelize.define("calender",{
listing_id:DATATYPE.INTEGER,
listdate:DATATYPE.DATE,
available:DATATYPE.TEXT,
price:DATATYPE.TEXT
});
return calender;
};
This is the code
now this is the error
module.js:471
throw err;
^
Error: Cannot find module 'E:\mindsumo\dataairbnb\models/..configconfig.json'
at Function.Module._resolveFilename (module.js:469:15)
at Function.Module._load (module.js:417:25)
at Module.require (module.js:497:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (E:\mindsumo\dataairbnb\models\index.js:8:17)
at Module._compile (module.js:570:32)
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> (E:\mindsumo\dataairbnb\server.js:10:11)
at Module._compile (module.js:570:32)
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.runMain (module.js:604:10)
at run (bootstrap_node.js:390:7)
at startup (bootstrap_node.js:150:9)
at bootstrap_node.js:505:3
Error while making model
node_modules/.bin/sequelize model:generate --name calender1 --attributes
listing_id:int, listdate:date, available:text, price:text
node_modules/.bin/sequelize model:generate --name calender1 --attributes listing_id:int, lis
tdate:date, available:text, price:text
Sequelize CLI [Node: 6.10.3, CLI: 3.0.0, ORM: 3.30.4]
E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:1079
else throw err
^
TypeError: Cannot read property 'toUpperCase' of undefined
at eval (lodash.templateSources[0]:18:32)
at Array.forEach (native)
at eval (lodash.templateSources[0]:14:26)
at Object.render (E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\lib\helpers\template-helper.js:26:54)
at Object.generateFileContent
(E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\helpers\model-
helper.js:31:37)
at Object.generateFile (E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\lib\helpers\model-helper.js:41:49)
at Object.exports.handler (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\commands\model_generate.js:32:27)
at Object.self.runCommand (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\lib\command.js:233:22)
at Object.Yargs.self._parseArgs (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:990:30)
at Object.get [as argv] (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\node_modules\yargs\yargs.js:927:19)
at Object.<anonymous> (E:\mindsumo\studyairbnb\node_modules\sequelize-cli\lib\sequelize:84:15)
at Module._compile (module.js:570:32)
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)
E:\mindsumo\studyairbnb\node_modules\sequelize-
cli\node_modules\yargs\yargs.js:1079
else throw err
^
If you used Express framework, this example help you a lot:
https://github.com/sequelize/express-example/tree/master/models
I too had problems with Sequelize in the start.
Check especially:
models/index.js
models/user.js
routes/index.js

JSON.parse failing if i pass ISODate

I have the below sample code which is failing if i pass ISODate in JSON object
var data =[{"$match":{"CREATED_DATE":{"$gt":ISODate("2015-07-29T17:30:00.000Z"),"$lt":ISODate("2015-07-30T09:00:00.000Z")}}}]
var update=JSON.parse(data);
Below is the error
/home/ubuntu/rr.js:1
name) { var data =[{"$match":{"EPS_TRANSACTION.CREATED_DATE":{"$gt":ISODate("2
^
ReferenceError: ISODate is not defined
at Object.<anonymous> (/home/ubuntu/rr.js:1:123)
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)
at startup (node.js:119:16)
at node.js:901:3
I am unable to handle the error,any solution will be much helpful

nodejs mysql (libmysqlclient)

I use https://github.com/calzoneman/sync project and get this error. I'm new to nodejs. How to fix this?
I done all in installation manual
root#srv:/var/www/synch# node server.js
Starting CyTube v1.9.5
/var/www/synch/node_modules/mysql-libmysqlclient/lib/mysql-libmysqlclient.js:208
MysqlConnectionQueued.prototype = new bindings.MysqlConnection();
^
TypeError: Cannot read property 'MysqlConnection' of null
at Object.<anonymous> (/var/www/synch/node_modules/mysql-libmysqlclient/lib/mysql-libmysqlclient.js:208:47)
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)
at Object.<anonymous> (/var/www/synch/auth.js:12:13)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)