javascript - เอกสารไม่ถูกกำหนดใน main.ts สำหรับการรัน "webpack --mode development"
ฉันได้ลองใช้คำสั่งนี้ "webpack --mode development" เพื่อรันโค้ดนี้
document.addEventListener('DOMContentLoaded', () => {
platformBrowserDynamic().bootstrapModule(AppModule)
.catch(err => console.log(err));
});
ในไฟล์ src/main.ts --- ฉันได้รับข้อผิดพลาดนี้...
document.addEventListener('DOMContentLoaded', function () {
^
ReferenceError: document is not defined
- main.ts:95362 Object../node_modules/html-webpack-plugin/lib/loader.js!./src/main.ts
/home/glad/Documents/glpdesktop-ang/src/main.ts:95362:1
- main.ts:21 __webpack_require__
/home/glad/Documents/glpdesktop-ang/src/main.ts:21:30
- main.ts:70
/home/glad/Documents/glpdesktop-ang/src/main.ts:70:18
- main.ts:73
/home/glad/Documents/glpdesktop-ang/src/main.ts:73:10
- index.js:247 HtmlWebpackPlugin.evaluateCompilationResult
[glpdesktop-ang]/[html-webpack-plugin]/index.js:247:28
- index.js:161 Promise.resolve.then.then.then.compiledTemplate
[glpdesktop-ang]/[html-webpack-plugin]/index.js:161:23
- next_tick.js:188 process._tickCallback
internal/process/next_tick.js:188:7
มีใครช่วยฉันแก้ปัญหานี้ได้ไหม? ขอบคุณ ...