Node.js 中使用 path 模块构建输出路径
The code you provided is incorrect. It should be 'require' instead of 'request' in the first line. Here's the corrected code:
const path = require('path');
module.exports = {
entry: './src/main.ts',
output: {
filename: 'bundle.js',
path: path.resolve(__dirname, 'dist/'),
}
}
In the corrected code, we use the 'require' function to import the 'path' module, which is a built-in module in Node.js. We then export an object with the 'entry' and 'output' properties. The 'entry' property specifies the entry point of the application, which is './src/main.ts'. The 'output' property specifies the output file name and path. The 'filename' property is set to 'bundle.js', and the 'path' property uses the 'path.resolve' method to resolve the absolute path of the 'dist/' directory relative to the current file's directory ('__dirname').
原文地址: https://www.cveoy.top/t/topic/pkc8 著作权归作者所有。请勿转载和采集!