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
javascript node.js
add a comment |
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
javascript node.js
Shouldn't it be '===' instead of '=' for the operator?
– Liam Strilchuk
Nov 11 at 15:14
Thats a syntax error of mongoose. trynpm install mongooseto 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
add a comment |
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
javascript node.js
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
javascript node.js
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. trynpm install mongooseto 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
add a comment |
Shouldn't it be '===' instead of '=' for the operator?
– Liam Strilchuk
Nov 11 at 15:14
Thats a syntax error of mongoose. trynpm install mongooseto 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
add a comment |
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
add a comment |
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
add a comment |
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
add a comment |
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
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
answered Nov 11 at 15:53
community wiki
Jonas Wilms
add a comment |
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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
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 mongooseto 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