英文:
How to resolve Webpack Exception on new machine
问题
当运行webpack时,我遇到了以下错误信息。
奇怪的是,在我的机器上,它可以正常工作。这是一个将近10年历史的旧项目。现在另一个开发人员要开始处理它,所以我们已经设置了他的机器与我的完全相同。但是会抛出这个异常,目前还不清楚是什么原因导致的。
这是一个使用webpack 2.6.1的Aurelia 1.0应用程序。后端使用的是Visual Studio 2022中的.net framework 4.8.0,并使用任务运行器资源管理器来运行webpack。
如果有任何建议,将不胜感激。我已经被困在这个问题上一段时间了。
以下是抛出异常的webpack代码:
function processDependency(dep) {
const reference = dep.getReference && dep.getReference();
if (!reference) return;
const module = reference.module;
const importedNames = reference.importedNames;
const oldUsed = module.used;
const oldUsedExports = module.usedExports;
if (!oldUsed || (importedNames && (!oldUsedExports || !isSubset(oldUsedExports, importedNames)))) {
processModule(module, importedNames);
}
}
我已经尝试过以下方法:
- 从webpack-cli运行:返回完全相同的错误消息。
- 以管理员身份运行:相同的错误消息。
英文:
I am getting the following error message when running webpack.
The oddity is that on my machine, it works fine. This is an old project nearly 10 years old that. Another developer is now going to be working on it and so we have set up his machine to be identical to mine. But this exception is thrown, and it is not clear what is causing this.
This is an Aurelia 1.0 app using webpack 2.6.1. Using .net framework 4.8.0 on the backend in Visual Studio 2022 and running webpack using the Task Runner Explorer.
Any suggestions would be appreciated. Have been stuck on this for a while.
C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE> cmd /c SET NODE_ENV=development&& webpack --color
C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\FlagDependencyUsagePlugin.js:56
const oldUsed = module.used;
^
TypeError: Cannot read properties of null (reading 'used')
at processDependency (C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\FlagDependencyUsagePlugin.js:56:29)
at C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\FlagDependencyUsagePlugin.js:46:43
at Array.forEach (<anonymous>)
at processDependenciesBlock (C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\FlagDependencyUsagePlugin.js:46:28)
at Compilation.<anonymous> (C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\FlagDependencyUsagePlugin.js:23:6)
at Compilation.applyPluginsBailResult1 (C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\node_modules\tapable\lib\Tapable.js:140:27)
at Compilation.seal (C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\Compilation.js:571:9)
at C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\Compiler.js:493:16
at C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\node_modules\tapable\lib\Tapable.js:289:11
at C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\Compilation.js:481:11
at C:\Dev\azure.dev.com\CSS.CRM.Jackpot\OE\node_modules\webpack\lib\Compilation.js:452:13
at processTicksAndRejections (node:internal/process/task_queues:78:11)
Process terminated with code 1.
This is the webpack code that is throwing the exception:
function processDependency(dep) {
const reference = dep.getReference && dep.getReference();
if(!reference) return;
const module = reference.module;
const importedNames = reference.importedNames;
const oldUsed = module.used;
const oldUsedExports = module.usedExports;
if(!oldUsed || (importedNames && (!oldUsedExports || !isSubset(oldUsedExports, importedNames)))) {
processModule(module, importedNames);
}
}
Have tried:
- Running from webpack-cli: Returns the exact same error message.
- Running as an administrator: Same error message.
答案1
得分: 0
这最终被调试成功了。
结果发现问题是由于机器上没有安装正确的TypeScript工具,导致没有JavaScript文件供webpack编译。
一旦安装了正确的工具,webpack就能按预期完成运行。
所以,如果你看到上述错误消息,请检查是否正在从TS编译js文件。如果没有,那就是需要解决的实际问题。
英文:
This was finally debugged.
Turns out it was a problem with the correct Typescript tools not being installed on the machine. So there was no javascript files for webpack to compile.
Once the correct tools were installed, then webpack ran as expected to completion.
So if you see the above error message, check to see if the js files are being compiled from TS. If not, that is the actual problem that needs to be resolved.
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论