undefined:1
SyntaxError: Unexpected end of JSON input
at JSON.parse (<anonymous>)
at Manifest.read (/var/www/html/app/node_modules/laravel-mix/src/Manife st.js:132:21)
at new Manifest (/var/www/html/app/node_modules/laravel-mix/src/Manifes t.js:14:43)
at Mix.initialize (/var/www/html/app/node_modules/laravel-mix/src/Mix.j s:49:25)
at Object.<anonymous> (/var/www/html/app/node_modules/laravel-mix/setup /webpack.config.js:18:5)
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 requireConfig (/var/www/html/app/node_modules/webpack/bin/convert-ar gv.js:96:18)
at /var/www/html/app/node_modules/webpack/bin/convert-argv.js:109:17
at Array.forEach (native)
at module.exports (/var/www/html/app/node_modules/webpack/bin/convert-a rgv.js:107:15)
I'm using webpack with laravel, but i keep getting this error,I dont have any idea where to look for this issue or what could be the problem.
Any tips?
Thanks!
Try deleting the mix-manifest.json file from /public
From https://github.com/JeffreyWay/laravel-mix/issues/772
The Error is from JSON parser. Generally speaking, it is caused by pass wrong parameter to JSON.parse. Double check if you are trying to parse some improper string to JSON. I used to have this error when I passed a normal string to JSON parser.
Related
I had to submit a form containing few parameters from localhost:2000/articles/new. I put the form method and action as <form action="/articles" method="POST">.
My post function is in article route and is like this:
router.post("/", (req, res) => {
console.log("sent")
console.log(req)
res.end()
})
My server.js file contains app.use("/articles", articleRouter)
I have used app.use(express.urlencoded({extended:false})) in server.js file
Now problem arises here:
==> when I use the app.use(express.urlencoded({extended:false})) I get error on submitting form.
The error I got is below:
C:\blog\node_modules\iconv-lite\encodings\dbcs-codec.js:1
SyntaxError: Invalid or unexpected token
at wrapSafe (internal/modules/cjs/loader.js:979:16)
at Module._compile (internal/modules/cjs/loader.js:1027:27)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.<anonymous> (C:\blog\node_modules\iconv-lite\encodings\index.js:12:5)
at Module._compile (internal/modules/cjs/loader.js:1063:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (internal/modules/cjs/helpers.js:88:18)
at Object.getCodec (C:\blog\node_modules\iconv-lite\lib\index.js:65:27)
at Object.getDecoder (C:\blog\node_modules\iconv-lite\lib\index.js:127:23)
==>But when I don't use it and submit the form the console.log of post function (router.post function ) works. I do not know what is the problem here please help me.
PROBLEM SOLVED FOR ME
I simply deleted node modules folder and again ran npm i on cmd.
This reinstalled all my node modules and its file, now it is working for me.
I am using the code from this example: Save JSON file to grab other data from it later
I copied and pasted this code just to test it and make sure that it worked and when I run it but when I do i get this error:
undefined:1
{
^
SyntaxError: Unexpected token in JSON at position 0
at JSON.parse (<anonymous>)
at Object.<anonymous> (/Users/vishnu/Documents/DiscordBot/index.js:5:19)
at Module._compile (internal/modules/cjs/loader.js:1156:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1176:10)
at Module.load (internal/modules/cjs/loader.js:1000:32)
at Function.Module._load (internal/modules/cjs/loader.js:899:14)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)
at internal/main/run_main_module.js:18:47
I'm new to node.js so i'm still trying to understand this a bit. Any help would be appreciated
This usually means that amount of { symbol mismatches amount of }
I am trying to send emails using the following doc on sendrid:
https://sendgrid.com/docs/Integrate/Code_Examples/v2_Mail/nodejs.html
My app.js looks like this:
var sendgrid = require('sendgrid')('SENDGRID_APIKEY');
When runnig npm start I get the following error:
var sendgrid = require('sendgrid')(conf);
^
TypeError: require(...) is not a function
at Object.<anonymous> (C:\Users\Grandullon\Desktop\angular\app.js:8:36)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
at Module.load (module.js:343:32)
at Function.Module._load (module.js:300:12)
at Module.require (module.js:353:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (C:\Users\Grandullon\Desktop\angular\bin\www:7:11)
at Module._compile (module.js:409:26)
at Object.Module._extensions..js (module.js:416:10)
Any ideas what I am doing wrong? conf is a variable where I store my API key.
I am using a clean express installation.
THANKS
My package.json can be looked here as requested:
http://pastebin.com/pGKWFReX
The latest documentation shows a different structure for initialization.
You should try doing
var sg = require('sendgrid').SendGrid(conf);
I following this link sails-generate-oauth to generate oauth with sails, i follow and make all steps as in the refered page say but i am getting this error:
root#Ubuntu:~/sailTests/guatour# sails lift
info: Starting app...
/root/sailTests/guatour/config/routes.js:50
'get /login': 'AuthController.login',
^^^^^^^^^^^^
SyntaxError: Unexpected string
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 /usr/local/lib/node_modules/sails/node_modules/include- all/index.js:129:29
at Array.forEach (native)
at requireAll (/usr/local/lib/node_modules/sails/node_modules/include-all/index.js:44:9)
at buildDictionary (/root/sailTests/guatour/node_modules/sails/node_modules/sails-build-dictionary/index.js:68:14)
at Function.module.exports.aggregate (/root/sailTests/guatour/node_modules/sails/node_modules/sails-build-dictionary/index.js:190:9)
at Array.loadOtherConfigFiles (/root/sailTests/guatour/node_modules/sails/lib/hooks/moduleloader/index.js:164:27)
at /root/sailTests/guatour/node_modules/sails/node_modules/async/lib/async.js:484:38
at _each (/root/sailTests/guatour/node_modules/sails/node_modules/async/lib/async.js:46:13)
at Object.async.auto (/root/sailTests/guatour/node_modules/sails/node_modules/async/lib/async.js:455:9)
Am i missing something?
Thanks for your help, regards.
Sorry, i found my error, it was a coma, before the (/) route (default).
This works on windows 7 localhost:
var User = mongoose.model(userDBName, userSchema);
But it gives this error for Debian VPS:
/home/node_modules/mongoose/lib/utils.js:28
return pluralize(name.toLowerCase());
^
TypeError: Cannot call method 'toLowerCase' of undefined
at exports.toCollectionName (/home/node_modules/mongoose/lib/utils.js:28:25)
at Mongoose.model (/home/node_modules/mongoose/lib/index.js:361:46)
at Object.<anonymous> (/home/XXX/nodejs/js/dbbase.js:54:21)
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> (/home/XXX/nodejs/js/db_read.js:1:76)
How to fix it?
The error was the name is really undefined, due to userDBName is undefined. It relative with 'nconf' and config.json. Just incorrect way to this file.