Invalid left-hand side in assignment nodejs











up vote
0
down vote

favorite












Hey this has been driving me crazy. I have this code, and the desired objective is to create a Author with the properties given. I have everything such as mongodb compass and mongod running, and after this error i updated npm + node. Still an error.



The code is here:



const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/playground')
.then(() => console.log('Connected to MongoDB...'))
.catch(err => console.error('Could not connect to MongoDB...', err));

const authorSchema = new mongoose.Schema({
name: String,
bio: String,
website: String,
})

const courseSchema = new mongoose.Schema({
name: String
})

const Author = mongoose.model('Author', authorSchema)

const Course = mongoose.model('Course',courseSchema)

async function createAuthor(name, bio, website) {
const author = new Author({
name,
bio,
website
});

const result = await author.save();
console.log(result);
}

async function createCourse(name, author) {
const course = new Course({
name,
author
});

const result = await course.save();
console.log(result);
}

async function listCourses() {
const courses = await Course
.find()
.select('name');
console.log(courses);
}

createAuthor('Mosh', 'My bio', 'My Website');

// createCourse('Node Course', 'authorId')

// listCourses();


And the given error is Here:



|| (selector['mapreduce'] && selector.out = 'inline')) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at /Users/eesamunir/node_modules/mongodb/lib/mongodb/index.js:29:17









share|improve this question






















  • Shouldn't it be '===' instead of '=' for the operator?
    – Liam Strilchuk
    Nov 11 at 15:14










  • Thats a syntax error of mongoose. try npm install mongoose to get the newest version, if the error still occurs report it
    – Jonas Wilms
    Nov 11 at 15:18










  • @JonasWilms Thanks so much man! it worked!
    – Eesa Munir
    Nov 11 at 15:51















up vote
0
down vote

favorite












Hey this has been driving me crazy. I have this code, and the desired objective is to create a Author with the properties given. I have everything such as mongodb compass and mongod running, and after this error i updated npm + node. Still an error.



The code is here:



const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/playground')
.then(() => console.log('Connected to MongoDB...'))
.catch(err => console.error('Could not connect to MongoDB...', err));

const authorSchema = new mongoose.Schema({
name: String,
bio: String,
website: String,
})

const courseSchema = new mongoose.Schema({
name: String
})

const Author = mongoose.model('Author', authorSchema)

const Course = mongoose.model('Course',courseSchema)

async function createAuthor(name, bio, website) {
const author = new Author({
name,
bio,
website
});

const result = await author.save();
console.log(result);
}

async function createCourse(name, author) {
const course = new Course({
name,
author
});

const result = await course.save();
console.log(result);
}

async function listCourses() {
const courses = await Course
.find()
.select('name');
console.log(courses);
}

createAuthor('Mosh', 'My bio', 'My Website');

// createCourse('Node Course', 'authorId')

// listCourses();


And the given error is Here:



|| (selector['mapreduce'] && selector.out = 'inline')) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at /Users/eesamunir/node_modules/mongodb/lib/mongodb/index.js:29:17









share|improve this question






















  • Shouldn't it be '===' instead of '=' for the operator?
    – Liam Strilchuk
    Nov 11 at 15:14










  • Thats a syntax error of mongoose. try npm install mongoose to get the newest version, if the error still occurs report it
    – Jonas Wilms
    Nov 11 at 15:18










  • @JonasWilms Thanks so much man! it worked!
    – Eesa Munir
    Nov 11 at 15:51













up vote
0
down vote

favorite









up vote
0
down vote

favorite











Hey this has been driving me crazy. I have this code, and the desired objective is to create a Author with the properties given. I have everything such as mongodb compass and mongod running, and after this error i updated npm + node. Still an error.



The code is here:



const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/playground')
.then(() => console.log('Connected to MongoDB...'))
.catch(err => console.error('Could not connect to MongoDB...', err));

const authorSchema = new mongoose.Schema({
name: String,
bio: String,
website: String,
})

const courseSchema = new mongoose.Schema({
name: String
})

const Author = mongoose.model('Author', authorSchema)

const Course = mongoose.model('Course',courseSchema)

async function createAuthor(name, bio, website) {
const author = new Author({
name,
bio,
website
});

const result = await author.save();
console.log(result);
}

async function createCourse(name, author) {
const course = new Course({
name,
author
});

const result = await course.save();
console.log(result);
}

async function listCourses() {
const courses = await Course
.find()
.select('name');
console.log(courses);
}

createAuthor('Mosh', 'My bio', 'My Website');

// createCourse('Node Course', 'authorId')

// listCourses();


And the given error is Here:



|| (selector['mapreduce'] && selector.out = 'inline')) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at /Users/eesamunir/node_modules/mongodb/lib/mongodb/index.js:29:17









share|improve this question













Hey this has been driving me crazy. I have this code, and the desired objective is to create a Author with the properties given. I have everything such as mongodb compass and mongod running, and after this error i updated npm + node. Still an error.



The code is here:



const mongoose = require('mongoose');

mongoose.connect('mongodb://localhost/playground')
.then(() => console.log('Connected to MongoDB...'))
.catch(err => console.error('Could not connect to MongoDB...', err));

const authorSchema = new mongoose.Schema({
name: String,
bio: String,
website: String,
})

const courseSchema = new mongoose.Schema({
name: String
})

const Author = mongoose.model('Author', authorSchema)

const Course = mongoose.model('Course',courseSchema)

async function createAuthor(name, bio, website) {
const author = new Author({
name,
bio,
website
});

const result = await author.save();
console.log(result);
}

async function createCourse(name, author) {
const course = new Course({
name,
author
});

const result = await course.save();
console.log(result);
}

async function listCourses() {
const courses = await Course
.find()
.select('name');
console.log(courses);
}

createAuthor('Mosh', 'My bio', 'My Website');

// createCourse('Node Course', 'authorId')

// listCourses();


And the given error is Here:



|| (selector['mapreduce'] && selector.out = 'inline')) {
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

ReferenceError: Invalid left-hand side in assignment
at createScript (vm.js:80:10)
at Object.runInThisContext (vm.js:139:10)
at Module._compile (module.js:617:28)
at Object.Module._extensions..js (module.js:664:10)
at Module.load (module.js:566:32)
at tryModuleLoad (module.js:506:12)
at Function.Module._load (module.js:498:3)
at Module.require (module.js:597:17)
at require (internal/module.js:11:18)
at /Users/eesamunir/node_modules/mongodb/lib/mongodb/index.js:29:17






javascript node.js






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Nov 11 at 15:06









Eesa Munir

22




22












  • Shouldn't it be '===' instead of '=' for the operator?
    – Liam Strilchuk
    Nov 11 at 15:14










  • Thats a syntax error of mongoose. try npm install mongoose to get the newest version, if the error still occurs report it
    – Jonas Wilms
    Nov 11 at 15:18










  • @JonasWilms Thanks so much man! it worked!
    – Eesa Munir
    Nov 11 at 15:51


















  • Shouldn't it be '===' instead of '=' for the operator?
    – Liam Strilchuk
    Nov 11 at 15:14










  • Thats a syntax error of mongoose. try npm install mongoose to get the newest version, if the error still occurs report it
    – Jonas Wilms
    Nov 11 at 15:18










  • @JonasWilms Thanks so much man! it worked!
    – Eesa Munir
    Nov 11 at 15:51
















Shouldn't it be '===' instead of '=' for the operator?
– Liam Strilchuk
Nov 11 at 15:14




Shouldn't it be '===' instead of '=' for the operator?
– Liam Strilchuk
Nov 11 at 15:14












Thats a syntax error of mongoose. try npm install mongoose to get the newest version, if the error still occurs report it
– Jonas Wilms
Nov 11 at 15:18




Thats a syntax error of mongoose. try npm install mongoose to get the newest version, if the error still occurs report it
– Jonas Wilms
Nov 11 at 15:18












@JonasWilms Thanks so much man! it worked!
– Eesa Munir
Nov 11 at 15:51




@JonasWilms Thanks so much man! it worked!
– Eesa Munir
Nov 11 at 15:51












1 Answer
1






active

oldest

votes

















up vote
1
down vote













As the error does not occur in your code, it has to be one from mongoose. It looks like that SyntaxError was fixed already, so just get the new fixed version with:



  npm install mongoose





share|improve this answer























    Your Answer






    StackExchange.ifUsing("editor", function () {
    StackExchange.using("externalEditor", function () {
    StackExchange.using("snippets", function () {
    StackExchange.snippets.init();
    });
    });
    }, "code-snippets");

    StackExchange.ready(function() {
    var channelOptions = {
    tags: "".split(" "),
    id: "1"
    };
    initTagRenderer("".split(" "), "".split(" "), channelOptions);

    StackExchange.using("externalEditor", function() {
    // Have to fire editor after snippets, if snippets enabled
    if (StackExchange.settings.snippets.snippetsEnabled) {
    StackExchange.using("snippets", function() {
    createEditor();
    });
    }
    else {
    createEditor();
    }
    });

    function createEditor() {
    StackExchange.prepareEditor({
    heartbeatType: 'answer',
    convertImagesToLinks: true,
    noModals: true,
    showLowRepImageUploadWarning: true,
    reputationToPostImages: 10,
    bindNavPrevention: true,
    postfix: "",
    imageUploader: {
    brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
    contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
    allowUrls: true
    },
    onDemand: true,
    discardSelector: ".discard-answer"
    ,immediatelyShowMarkdownHelp:true
    });


    }
    });














    draft saved

    draft discarded


















    StackExchange.ready(
    function () {
    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250035%2finvalid-left-hand-side-in-assignment-nodejs%23new-answer', 'question_page');
    }
    );

    Post as a guest















    Required, but never shown

























    1 Answer
    1






    active

    oldest

    votes








    1 Answer
    1






    active

    oldest

    votes









    active

    oldest

    votes






    active

    oldest

    votes








    up vote
    1
    down vote













    As the error does not occur in your code, it has to be one from mongoose. It looks like that SyntaxError was fixed already, so just get the new fixed version with:



      npm install mongoose





    share|improve this answer



























      up vote
      1
      down vote













      As the error does not occur in your code, it has to be one from mongoose. It looks like that SyntaxError was fixed already, so just get the new fixed version with:



        npm install mongoose





      share|improve this answer

























        up vote
        1
        down vote










        up vote
        1
        down vote









        As the error does not occur in your code, it has to be one from mongoose. It looks like that SyntaxError was fixed already, so just get the new fixed version with:



          npm install mongoose





        share|improve this answer














        As the error does not occur in your code, it has to be one from mongoose. It looks like that SyntaxError was fixed already, so just get the new fixed version with:



          npm install mongoose






        share|improve this answer














        share|improve this answer



        share|improve this answer








        answered Nov 11 at 15:53


























        community wiki





        Jonas Wilms































            draft saved

            draft discarded




















































            Thanks for contributing an answer to Stack Overflow!


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.





            Some of your past answers have not been well-received, and you're in danger of being blocked from answering.


            Please pay close attention to the following guidance:


            • Please be sure to answer the question. Provide details and share your research!

            But avoid



            • Asking for help, clarification, or responding to other answers.

            • Making statements based on opinion; back them up with references or personal experience.


            To learn more, see our tips on writing great answers.




            draft saved


            draft discarded














            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53250035%2finvalid-left-hand-side-in-assignment-nodejs%23new-answer', 'question_page');
            }
            );

            Post as a guest















            Required, but never shown





















































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown

































            Required, but never shown














            Required, but never shown












            Required, but never shown







            Required, but never shown







            Popular posts from this blog

            List item for chat from Array inside array React Native

            Thiostrepton

            Caerphilly