Multiparty file upload issue with body parser using angularjs and nodejs

Trying to upload a file from Angularjs UI to nodejs server but facing issues with bodyparser, adding limit to it throws – “SyntaxError: Unexpected token – in JSON at position 0”, if limit not added throws – “Payload too large”

I am using connect-multiparty middleware to upload the file. Tried with {limit: ’50mb’} in bodyparser and without any limit as well.

UI Code –

$('#imgupload').on('change', function  (evt) {
   let uploadedFiles =;
   let formData = new FormData();
    for (var i = 0; i < uploadedFiles.length; i++) {
        formData.append("uploads[]", uploadedFiles[i], 
   let url =   "/upload";
       .then(function (response) {
           console.log("the file has been uploaded to local server 

Nodejs (server code)-

const  multipart  =  require('connect-multiparty');  
const  multipartMiddleware  =  multipart({ uploadDir:  './uploads' });

app.use(bodyParser.json({limit: '50mb'}));

app.use(bodyParser.urlencoded({extended: true}));'/upload', multipartMiddleware, (req, res) => {  
        'message': 'File uploaded succesfully.'

Source: AngularJS