Ok, for some reason, I tested something just to see if it would work and it gave me an error. I can't figure out what's wrong, it looks fine to me, I've compared and searched for an hour and nothing. I could be doing something really stupid but here.
This is bot.js
const botSettings = require("./botsettings.json");
console.log(botSettings.token);
console.log(botSettings.prefix);
This is package.json
{
"name": "ultibot",
"version": "0.0.1",
"description": "a bot for the discord server The Ritual",
"main": "bot.js",
"author": "Rituliant",
"license": "ISC",
"dependencies": {
"discord.js": "^11.3.0"
}
}
This is botsettings.json
{
"token": "thisisnormallyalongstringofrandomletters",
"prefix": "!",
}
The full error is this
module.js:665
throw err;
^
SyntaxError: C:\Users\quinb\DiscordBotJS\botsettings.json: Unexpected token } in JSON at position 98
at JSON.parse (<anonymous>)
at Object.Module._extensions..json (module.js:662:27)
at Module.load (module.js:556:32)
at tryModuleLoad (module.js:499:12)
at Function.Module._load (module.js:491:3)
at Module.require (module.js:587:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (C:\Users\quinb\DiscordBotJS\bot.js:1:83)
at Module._compile (module.js:643:30)
at Object.Module._extensions..js (module.js:654:10)
botsettings.json should be
{
"token": "thisisnormallyalongstringofrandomletters",
"prefix": "!"
}
i.e. no comma after the prefix value.
JSON, unlike modern JavaScript, does not allow trailing commas in its object notation. So the final } in botsettings.json is indeed unexpected, because of the comma before it:
{
"token": "thisisnormallyalongstringofrandomletters",
"prefix": "!",
^----- Here
}
That's only valid JSON if you remove that comma:
{
"token": "thisisnormallyalongstringofrandomletters",
"prefix": "!"
}
Related
I have tried searching the web and deleting the node module twice and restarting the pc nothing seems to work.
This is the exact error.
Starting project at C:\Users\Admire\OneDrive\Documents\Projects\project-dharan\app
JsonFileError: Error parsing JSON:
└─ Cause: SyntaxError: Unexpected token in JSON at position 0
1 |
| ^
JsonFileError: Error parsing JSON:
└─ Cause: SyntaxError: Unexpected token in JSON at position 0
1 |
| ^
at parseJsonString (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\json-file\build\JsonFile.js:160:19)
at Function.readAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\json-file\build\JsonFile.js:139:12)
at async getPackageVersionAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\cli\build\src\start\doctor\dependencies\validateDependenciesVersions.js:140:25)
at async Promise.all (index 7)
at async resolvePackageVersionsAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\cli\build\src\start\doctor\dependencies\validateDependenciesVersions.js:118:44)
at async getVersionedDependenciesAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\cli\build\src\start\doctor\dependencies\validateDependenciesVersions.js:88:29)
at async validateDependenciesVersionsAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\cli\build\src\start\doctor\dependencies\validateDependenciesVersions.js:49:27)
at async startAsync (C:\Users\Admire\AppData\Roaming\npm\node_modules\expo\node_modules#expo\cli\build\src\start\startAsync.js:109:9)
I have found the solution in the subredit for the identical problem but there is no way I can follow the solution mentioned in the link
this is my package json file
{
"name": "project-dharan",
"version": "1.0.0",
"main": "node_modules/expo/AppEntry.js",
"scripts": {
"start": "expo start",
"android": "expo start --android",
"ios": "expo start --ios",
"web": "expo start --web"
},
"dependencies": {
"#react-navigation/native": "^6.1.2",
"#react-navigation/native-stack": "^6.9.8",
"expo": "^47.0.13",
"expo-status-bar": "~1.4.2",
"react": "18.1.0",
"react-dom": "18.1.0",
"react-native": "0.70.5",
"react-native-safe-area-context": "4.4.1",
"react-native-screens": "~3.18.0",
"react-native-svg": "13.4.0",
"react-native-svg-transformer": "^1.0.0",
"react-native-web": "~0.18.7"
},
"devDependencies": {
"#babel/core": "^7.12.9"
},
"private": true
}
Have an issue with feathersjs-authentication. Calling a service which requires authorization without an Authorization header causes this stacktrace in console:
at Object.<anonymous> (/User Analytics/Backend/node_modules/feathers-
errors/lib/index.js:69:27)
at Module._compile (module.js:571:32)
at Object.Module._extensions..js (module.js:580:10)
at Module.load (module.js:488:32)
at tryModuleLoad (module.js:447:12)
at Function.Module._load (module.js:439:3)
at Module.require (module.js:498:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/User Analytics/Backend/node_modules/feathers-
rest/lib/wrappers.js:13:23)
at Module._compile (module.js:571:32)
client receives even more strange response:
{
"name": "GeneralError",
"message": "`toJSON` takes 0 argument, 1 provided
after:\nr.db(\"user_analytics\").table(\"fbusers\")",
"code": 500,
"className": "general-error",
"data": {},
"errors": {}
}
Client receives GeneralError instead of concrete error and proper code.
Dependency packages:
"dependencies": {
"body-parser": "^1.17.2",
"compression": "^1.6.2",
"cors": "^2.8.3",
"fb": "^2.0.0",
"feathers": "^2.1.3",
"feathers-authentication": "^1.2.6",
"feathers-authentication-hooks": "^0.1.4",
"feathers-authentication-jwt": "^0.3.1",
"feathers-authentication-local": "^0.4.3",
"feathers-configuration": "^0.4.1",
"feathers-errors": "^2.8.1",
"feathers-hooks": "^2.0.1",
"feathers-hooks-common": "^3.5.5",
"feathers-rest": "^1.7.3",
"feathers-rethinkdb": "^0.4.3",
"feathers-socketio": "^2.0.0",
"helmet": "^3.6.1",
"lodash": "^4.17.4",
"node-rest-client": "^3.1.0",
"rethinkdbdash": "^2.3.29",
"serve-favicon": "^2.4.3",
"winston": "^2.3.1"
},
I have the following code...
[
{
"number": 0,
"color": "blue",
"content": require('./first-card.pug')
}
...
]
When I try to run Webpack I see...
ERROR in ./src/app/jg/cards/cards.json
Module build failed: SyntaxError: Unexpected token r
at Object.parse (native)
Do I need to escape or something?
I am trying to assign an array stored in json into an array in a controller when I press a button. I have run my json against several online validators and all of them claim my json is valid. However, when I go to parse it I get an unexpected token error.
I have double checked everything and I think everything closely mirrors the tutorial I am going through at https://docs.angularjs.org/tutorial/step_05 but it just doesn't want to work.
Relevant Controller Lines:
angular.module('myApp.controllers', [])
.controller('PlayerAdditionCtrl', function($scope, $http) {
$scope.players = [];
$scope.loadDefaults = function()
{
$http.get('defaults.json').success(function(array)
{
//assignment here
});
}
});
Complete json:
[
{
"name": "Mike",
"color": "teal"
},
{
"name": "Madre",
"color": "seagreen"
},
{
"name": "Anthony",
"color": "royalblue"
},
{
"name": "GI-Joe",
"color": "olivedrab"
}
]
Complete error text from chrome:
SyntaxError: Unexpected token {
at Object.parse (native)
at fromJson (http://localhost:8000/app/bower_components/angular/angular.js:1078:14)
at $HttpProvider.defaults.defaults.transformResponse (http://localhost:8000/app/bower_components/angular/angular.js:7317:18)
at http://localhost:8000/app/bower_components/angular/angular.js:7292:12
at Array.forEach (native)
at forEach (http://localhost:8000/app/bower_components/angular/angular.js:323:11)
at transformData (http://localhost:8000/app/bower_components/angular/angular.js:7291:3)
at transformResponse (http://localhost:8000/app/bower_components/angular/angular.js:7963:17)
at wrappedCallback (http://localhost:8000/app/bower_components/angular/angular.js:11319:81)
at http://localhost:8000/app/bower_components/angular/angular.js:11405:26 angular.js:9778
(anonymous function) angular.js:9778
(anonymous function) angular.js:7216
wrappedCallback angular.js:11322
(anonymous function) angular.js:11405
Scope.$eval angular.js:12412
Scope.$digest angular.js:12224
Scope.$apply angular.js:12516
done angular.js:8204
completeRequest angular.js:8412
xhr.onreadystatechange angular.js:8351
Check your json/and/or/pathtojson again your code works for me
http://plnkr.co/edit/AGdJ9SasmHn74RQe8xX2?p=preview
I am sending this json to express app and getting parsing error:
{
"first_name" : "User",
"last_name" : "one",
"country" : "IN",
"dob" : "1980-04-11",
"email": "userone#gmail.com",
"password": "abcd12345",
"username": "usernameone"
}
The error is:
SyntaxError: Unexpected string
at Object.parse (native)
at IncomingMessage.<anonymous> (/Users/saransh2012/Developer/vypics/node_modules/express/node_modules/connect/lib/middleware/json.js:76:27)
at IncomingMessage.EventEmitter.emit (events.js:92:17)
at _stream_readable.js:910:16
at process._tickCallback (node.js:415:13)
I think the error is in the date thing, what am I doing wrong?? Please help.