本文介绍了错误:internal/modules/cjs/loader.js:968 抛出错误;节点模块?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在关注 这个 YouTube 教程系列,但突然在运行服务器时我得到了这个问题我尝试将 node 重新卸载到最新的稳定版本.
I was following this YouTube tutorials series but suddenly while running server i got this problemI 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: []
}
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
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"
}
}
推荐答案
将 scr/app.js
更改为 包中的
src/app.js
.json
change scr/app.js
to src/app.js
in your package.json
这篇关于错误:internal/modules/cjs/loader.js:968 抛出错误;节点模块?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!