gpt4 book ai didi

javascript - 找不到模块 : internal/modules/cjs/loader. js:969

转载 作者:行者123 更新时间:2023-12-03 22:21:15 24 4
gpt4 key购买 nike

我想运行我的应用程序,但突然收到此错误。为什么?
这就是我工作的订单的样子。

./
├─ app.js
├─ .env
├─ .gitignore
├─ node modules/
│ └─ ...
├─ package.json
├─ package-lock.json
├─ models/
│ └─ advertiser/
│ └─ advertiser_info.js
├─ customer
└─ db/
└─ advertiser_db.js
应用程序.js:
const express = require("express");
const app = express();

/* ******** Database Connection ********* */
var db = require("./db/advertiser_db");


db.sequelize.sync().then(() => {
console.log("Database connection successfull");
app.listen(process.env.PORT, () => {
console.log("Express listening on " + process.env.PORT);

})
});
db/advertiser_db.js:
require("dotenv").config();
const Sequelize = require("sequelize");
const sequelize = new Sequelize(`${process.env.DB_NAME}`, `${process.env.DB_USERNAME}`, `${process.env.DB_PW}`, {
host: `${process.env.DB_HOST}`,
dialect: "postgres"
});

const db = {};

db.n_advertiser = sequelize.import(__dirname + "/models/advertiser/advertiser_info.js");
db.sequelize = sequelize;
db.Sequelize = Sequelize;

module.exports = db;
模型/广告商/advertiser_info.js:
module.exports = (sequelize, Sequelize) => {
return sequelize.define("advertiser", {
blabla: {
type: Sequelize.STRING,
allowNull: false,
},
blabla: {
type: Sequelize.STRING,
allowNull: false,
},
email: {
type: Sequelize.STRING,
allowNull: false,
validate: {
isEmail: true
}
},
hashedPw: {
type: Sequelize.STRING,
allowNull: false
},
blabla: {
type: Sequelize.STRING,
allowNull: false,
},
blabla: {
type: Sequelize.STRING,
allowNull: false
},
blabla: {
type: Sequelize.BOOLEAN,
allowNull: false,
defaultValue: true,

}
})
}
如果我运行 app.js 文件,我会看到以下错误:
internal/modules/cjs/loader.js:969
throw err;
^

Error: Cannot find module '/Users/yildirim/Desktop/nn_backend/db/models/advertiser/advertiser_info.js'
Require stack:
- /Users/yildirim/Desktop/nn_backend/node_modules/sequelize/lib/sequelize.js
- /Users/yildirim/Desktop/nn_backend/node_modules/sequelize/index.js
- /Users/yildirim/Desktop/nn_backend/db/advertiser_db.js
- /Users/yildirim/Desktop/nn_backend/app.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:966:15)
at Function.Module._load (internal/modules/cjs/loader.js:842:27)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Sequelize.import (/Users/yildirim/Desktop/nn_backend/node_modules/sequelize/lib/sequelize.js:481:62)
at Object.<anonymous> (/Users/yildirim/Desktop/nn_backend/db/advertiser_db.js:10:40)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
at Module.require (internal/modules/cjs/loader.js:1026:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (/Users/yildirim/Desktop/nn_backend/app.js:5:10)
at Module._compile (internal/modules/cjs/loader.js:1138:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1158:10)
at Module.load (internal/modules/cjs/loader.js:986:32)
at Function.Module._load (internal/modules/cjs/loader.js:879:14)
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: [
'/Users/yildirim/Desktop/nn_backend/node_modules/sequelize/lib/sequelize.js',
'/Users/yildirim/Desktop/nn_backend/node_modules/sequelize/index.js',
'/Users/yildirim/Desktop/nn_backend/db/advertiser_db.js',
'/Users/yildirim/Desktop/nn_backend/app.js'
]
}
我看到它向我展示了一条根本不存在的路径。为什么?我从未定义过该路径:
'/Users/yildirim/Desktop/nn_backend/db/models/advertiser/advertiser_info.js'
感谢您提供有用的答案。

最佳答案

尝试从原始文件夹再次打开您的文件。我有同样的问题,现在它已经修复了,在更改位置后。

关于javascript - 找不到模块 : internal/modules/cjs/loader. js:969,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/62436868/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com