Back End Development and APIs - Exercise Tracker

Hello! I’m having a issue with my code and i can’t understand what im doing wrong. I think its a replit issue.

Whenever i try to run my code i get this error:

/home/runner/boilerplate-project-exercisetracker/server.js:6
const mongoose, { Schema } =require('mongoose')
      ^^^^^^^^

SyntaxError: Missing initializer in const declaration
    at wrapSafe (internal/modules/cjs/loader.js:915:16)
    at Module._compile (internal/modules/cjs/loader.js:963:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1027:10)
    at Module.load (internal/modules/cjs/loader.js:863:32)
    at Function.Module._load (internal/modules/cjs/loader.js:708:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:60:12)
    at internal/main/run_main_module.js:17:47
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! fcc-exercise-tracker@0.1.0 start: `node server.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the fcc-exercise-tracker@0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/runner/.npm/_logs/2022-03-20T17_17_32_384Z-debug.log
exit status 1
 

Is this a replit issue? or mongoose?

Here is the link to my replit :

This is not a valid syntax.
It should be either this:

const mongoose = require('mongoose')
const Schema = mongoose.Schema

or this:

import mongoose, { Schema } from 'mongoose'

Thanks a lot! the first solution worked.
Which is this one:
``const mongoose = require(‘mongoose’)

const Schema = mongoose.Schema
``

Thanks a lot again!

This topic was automatically closed 182 days after the last reply. New replies are no longer allowed.