4

I was following this YouTube tutorials series but suddenly while running server i got this problem I tried re-uninstalling node to latest stable version.

internal/modules/cjs/loader.js:968
  throw err;
  ^

Error: Cannot find module 'D:\DATA\Learning\Creations\WEB\website\tabs tracker\Vue-and-Express.JS\server\scr\app.js'
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
    at Function.Module._load (internal/modules/cjs/loader.js:841:27)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:71:12)
    at internal/main/run_main_module.js:17:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

code of app.js

const express = require('express')
const bodyParser = require('body-parser')
const morgan = require('morgan')
const cors = require('cors')
const { sequelize } = require('./models')
const config = require('./config/config')

const app = express()

app.use(morgan('combined'))
app.use(bodyParser.json())
app.use(cors())

require('./routes')(app)

sequelize.sync().then(() => {
  app.listen(config.port)
  console.log(`Serverstarted on port ${config.port}`)
})

package.json

{
  "name": "server",
  "version": "1.0.0",
  "description": "",
  "main": "server.js",
  "scripts": {
    "start": "node ./node_modules/nodemon/bin/nodemon.js scr/app.js --exec \"npm run lint && node\"",
    "lint": "./node_modules/.bin/eslint **/*.js"
  },
  "keywords": [],
  "author": "",
  "license": "ISC",
  "dependencies": {
    "body-parser": "^1.19.0",
    "cors": "^2.8.5",
    "express": "^4.17.1",
    "joi": "^17.2.0",
    "morgan": "^1.10.0",
    "sequelize": "^6.3.4",
    "sqlite3": "^5.0.0"
  },
  "devDependencies": {
    "eslint": "^7.7.0",
    "nodemon": "^2.0.4",
    "eslint-config-standard": "^14.1.1",
    "eslint-plugin-import": "^2.22.0",
    "eslint-plugin-node": "^11.1.0",
    "eslint-plugin-promise": "^4.2.1",
    "eslint-plugin-standard": "^4.0.1",
    "eslint-plugin-vue": "^6.2.2"
  }
}

RobC
  • 22,977
  • 20
  • 73
  • 80
Shadow
  • 121
  • 1
  • 1
  • 8

3 Answers3

2

I think you there is a typo somewhere in your code where you imported 'app' as /scr/app instead of src/app

Eazash
  • 129
  • 1
  • 8
1

change scr/app.js to src/app.js in your package.json

Karl L
  • 1,645
  • 1
  • 7
  • 11
0

Faced this while using #vuejs and the fix for me was to delete the package.lock.json file and the node_modules folder. Then I ran npm i and then npm run serve worked well

Anjayluh
  • 1,647
  • 1
  • 13
  • 22