使用 Angular 9 使用特殊加载器

Yaz*_*rez 1 webpack angular angular9

我将我的项目升级到 Angular 9。我正在使用 SSR,升级我的webpack.config.js变成webpack.config.js.bak. 现在我正在尝试做ng build --prod && ng run [projectName]:server:production

\n\n

现在我收到此错误消息

\n\n
    ERROR in ./node_modules/canvas/build/Release/canvas.node 1:2\n    Module parse failed: Unexpected character \'\xef\xbf\xbd\' (1:2)\n    You may need an appropriate loader to handle this file type, currently no loaders are configured \n    to process this file. See https://webpack.js.org/concepts#loaders\n    (Source code omitted for this binary file)\n
Run Code Online (Sandbox Code Playgroud)\n\n

所以我尝试实现诸如此类的加载器node-loader,我需要知道我是否应该更新我的加载器server.ts,因为我可以看到webpack.config.js在我的情况下不再需要。

\n\n

编辑:

\n\n

我尝试过angular.json但仍然不起作用

\n\n
"server": {\n          "builder": "@angular-devkit/build-angular:server",\n          "options": {\n            "outputPath": "dist/server",\n            "externalDependencies": [\n              "fabric"\n            ],\n            "main": "server.ts",\n            "tsConfig": "src/tsconfig.server.json"\n          },\n
Run Code Online (Sandbox Code Playgroud)\n

小智 7

我有这个确切的问题。首先,你的“externalDependency”应该在 Angular.json 中设置为“canvas”。然后确保您安装了最新的稳定版本的节点。希望这可以帮助。