gpt4 book ai didi

node.js - 无法读取未定义的属性 'createSnapshot'

转载 作者:行者123 更新时间:2023-12-03 12:18:16 30 4
gpt4 key购买 nike

由于我使用了 Electron forge webpack 插件,当我执行 npm start , 在编译预加载脚本步骤后会导致错误。它说错误是 锻造厂内部 .
我检查了一下,这是文件观察器 api 中的错误,即 mainCompilation.fileSystemInfo未定义,因此无法读取 prop createSnapShot 函数。
我应该怎么做才能解决此错误并启动我的应用程序?
日志:

> datapack-planet@0.0.0 start D:\program\datapack-planet
> electron-forge start

√ Checking your system
√ Locating Application
You have set packagerConfig.ignore, the Electron Forge webpack plugin normally sets this automatically.

Your packaged app may be larger than expected if you dont ignore everything other than the '.webpack' folder
√ Preparing native dependencies
√ Compiling Main Process Code
√ Launch Dev Servers
√ Compiling Preload Scripts

An unhandled rejection has occurred inside Forge:
TypeError: Cannot read property 'createSnapshot' of undefined
at D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\webpack5\file-watcher-api.js:13:36
at new Promise (<anonymous>)
at Object.createSnapshot (D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\webpack5\file-watcher-api.js:12:10)
at D:\program\datapack-planet\node_modules\html-webpack-plugin\lib\cached-child-compiler.js:219:35
at processTicksAndRejections (internal/process/task_queues.js:93:5)

Electron Forge was terminated. Location:
{}
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! datapack-planet@0.0.0 start: `electron-forge start`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the datapack-planet@0.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\dell\AppData\Roaming\npm-cache\_logs\2021-01-22T04_33_47_591Z-debug.log
我的 package.json (不是全部,只有重要数据):
{
"main": "./.webpack/main",
"devDependencies": {
"@electron-forge/cli": "^6.0.0-beta.54",
"@electron-forge/maker-deb": "^6.0.0-beta.54",
"@electron-forge/maker-rpm": "^6.0.0-beta.54",
"@electron-forge/maker-squirrel": "^6.0.0-beta.54",
"@electron-forge/maker-zip": "^6.0.0-beta.54",
"@electron-forge/plugin-webpack": "^6.0.0-beta.54",
"@marshallofsound/webpack-asset-relocator-loader": "^0.5.0",
"@types/jquery": "^3.5.5",
"@types/node": "^14.14.22",
"electron": "^11.1.1",
"fork-ts-checker-webpack-plugin": "^6.1.0",
"html-loader": "^1.3.2",
"jquery": "^3.5.1",
"less": "^4.1.0",
"less-loader": "^7.2.1",
"node-loader": "^1.0.2",
"ts-loader": "^8.0.14",
"typescript": "^4.1.3",
"webpack": "^5.16.0",
"webpack-cli": "^4.4.0"
},
"dependencies": {
"electron-squirrel-startup": "^1.0.0",
"jquery": "^3.5.1"
},
"scripts": {
"start": "electron-forge start",
"package": "electron-forge package",
"make": "electron-forge make"
},
"config": {
"forge": {
"packagerConfig": {
"ignore": [
"\\.(idea|git)",
"config\\.json",
"[A-Z]",
"md$"
]
},
"makers": [
// There is some auto-generated settings, I didn't changed it.
// So I skip those configs.
],
"plugins": [
[
"@electron-forge/plugin-webpack",
{
"mainConfig": "./webpack.main.config.js",
"renderer": {
"config": "./webpack.renderer.config.js",
"entryPoints": [
{
"html": "./src/index.html",
"js": "./src/renderer.ts",
"name": "main_window"
}
]
}
}
]
]
}
}
}
解决 : 我重新启动项目。也许我错过了一些依赖项。我是从模板复制的,所以应该会按预期发生错误。

最佳答案

我的解决方法是删除 node_modulespackage-lock.json ,然后运行

npm install --legacy-peer-deps
非常现代的 npm 版本存在一个问题,这为您提供了似乎有效的旧安装规则

关于node.js - 无法读取未定义的属性 'createSnapshot',我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/65839447/

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