Open
Description
What version of pkg are you using?
6.2.0
What version of Node.js are you using?
22.13.0
What operating system are you using?
Windows 10
What CPU architecture are you using?
x86_64 intel 13600KF
What Node versions, OSs and CPU architectures are you building for?
node22-win-x64
Describe the Bug
Warning Cannot resolve 'path.join(dir_path, file)'
E:\Projects\web\zjq-admin\models\index.js
Dynamic require may fail at run time, because the requested file
is unknown at compilation time and not included into executable.
Use a string literal as an argument for 'require', or leave it
as is and specify the resolved file name in 'scripts' option.
Expected Behavior
How to solve it ?
To Reproduce
package.json
"scripts": [
"./bin/www.js",
"./models/examBatch.js",
"./models/grade.js",
"./models/user.js",
"./models/worker.js",
"./models/workerExamBatch.js"
],
Warning file in ./model/index.js
fs.readdirSync(__dirname)
.filter((file) => {
return (
file.indexOf(".") !== 0 &&
file !== basename &&
file.slice(-3) === ".js" &&
file.indexOf(".test.js") === -1
);
})
.forEach((file) => {
const model = require(path.join(__dirname, file))(
sequelize,
Sequelize.DataTypes,
);
models[model.name] = model;
});
Metadata
Metadata
Assignees
Labels
No labels