node.js - 模块构建失败(来自 ./node_modules/html-loader/dist/cjs.js):
问题描述
我正在尝试快速启动 ava electron webpack 和三个,但在该过程中出现了问题。
这是项目的存储库:
https://github.com/etiennerin/ecsy-three-electron-ava-quick-start
通过简单地尝试通过键入我的项目来使用我的项目,npm run dev
我收到以下错误消息:
我正在使用窗户。
我认为这个错误可能与我的 webpack-configuration 有关,在我尝试了一些 npm-update 之前,这似乎很奇怪:
'use strict'
import { app, BrowserWindow } from 'electron'
import * as path from 'path'
import { format as formatUrl } from 'url'
import * as THREE from '../../node_modules/three/build/three.module.js';
//import {World} from '../../node_modules/ecsy/build/ecsy.module.js';
const isDevelopment = process.env.NODE_ENV !== 'production'
// global reference to mainWindow (necessary to prevent window from being garbage collected)
let mainWindow
function createMainWindow() {
const window = new BrowserWindow({webPreferences: {nodeIntegration: true}})
if (isDevelopment) {
window.webContents.openDevTools()
}
if (isDevelopment) {
window.loadURL(`http://localhost:${process.env.ELECTRON_WEBPACK_WDS_PORT}`)
}
else {
window.loadURL(formatUrl({
pathname: path.join(__dirname, 'index.html'),
protocol: 'file',
slashes: true
}))
}
window.on('closed', () => {
mainWindow = null
})
window.webContents.on('devtools-opened', () => {
window.focus()
setImmediate(() => {
window.focus()
})
})
return window
}
// quit application when all windows are closed
app.on('window-all-closed', () => {
// on macOS it is common for applications to stay open until the user explicitly quits
if (process.platform !== 'darwin') {
app.quit()
}
})
app.on('activate', () => {
// on macOS it is common to re-create a window even after all windows have been closed
if (mainWindow === null) {
mainWindow = createMainWindow()
}
})
// create main BrowserWindow when electron is ready
app.on('ready', () => {
mainWindow = createMainWindow()
})
和我最新的 package.json :
{
"name": "electron-webpack-quick-start",
"version": "0.0.0",
"license": "MIT",
"scripts": {
"start": "electron-webpack dev",
"dev": "electron-webpack dev",
"compile": "electron-webpack",
"dist": "yarn compile && electron-builder",
"dist:dir": "yarn dist --dir -c.compression=store -c.mac.identity=null",
"test": "ava"
},
"dependencies": {
"source-map-support": "^0.5.16"
},
"ava": {
"files": [
"spec/**/*"
],
"require": [
"esm"
]
},
"devDependencies": {
"ava": "^3.5.1",
"ecsy": "^0.2.3",
"electron": "8.1.1",
"electron-builder": "^22.4.1",
"electron-webpack": "^2.7.4",
"esm": "^3.2.25",
"html-loader": "^1.0.0",
"three": "^0.112.1",
"webpack": "^4.42.0"
}
}
非常感谢您的每一条建议!
解决方案
您是否尝试过清理并重新安装
rm -rf node_modules yarn.lock package-lock.json
npm install // or yarn
run webpack
推荐阅读
- javascript - 无法从 Node JS 更新 MongoDB 中的产品记录
- google-sheets - 如何通过匹配排序不同的列来导入行?
- sql - 错误 #1093 - 表被指定了两次,既作为“删除”的目标,又作为数据的单独源
- flutter - Flutter bloc注册问题
- android - Android Profiler 线程和进程按 Id 查找
- assembly - 我正在编写自己的基本操作系统,采用 NASM 16 位,它不断打印一个我没有告诉它的字符串
- python - 如何从 ABC 和另一个类继承
- javascript - 尝试访问脚本时使用useEffect在我的React项目上获取“TypeError:无法读取null的属性'classList'”?
- javascript - DiscordJS:仅替换 JSON 的特定部分
- macos - 错误:无法“发布升级”颤振工具。5 秒后重试...(还剩 9 次尝试)