Azure / Azure/api-management-developer-portal

Build-Function script is throwing an error

Open
#2,157 2 comments 0 reactions 0 assignees View on GitHub
Dominant language
TypeScript
Stars
545
Forks
360
PR merge metrics
No merged PRs in 30d

Description

We are using the self hosted version of the portal and running into an error during the Build-Function command. This error also occurs in the latest azure dev portal code, not just our version.

Reproduction Steps:
1) Run the command "npm run build-function"
2) The output will show that an error is occurring due to a missing canvas npm package.

The outputted error is a mistake in my opinion. Canvas is an optional dependency of the jsdom npm package. There are other optional npm package dependencies (for example, bufferutil and utf-8-validate) in the latest azure dev portal code, but these just throw warnings. The error that is thrown due to the optional canvas package is causing our azure pipeline to fail because the build-function command returns a non zero value because of this error.

Relevant output from running command "npm run build-function"

`WARNING in ./node_modules/ws/lib/buffer-util.js 117:23-44
Module not found: Error: Can't resolve 'bufferutil' in '...\node_modules\ws\lib'
@ ./node_modules/ws/lib/receiver.js 12:42-66
@ ./node_modules/ws/index.js 7:21-46
@ ./node_modules/jsdom/lib/jsdom/living/websockets/WebSocket-impl.js 7:18-31
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js 21:22-83
@ ./node_modules/jsdom/lib/api.js 13:25-61
@ ./node_modules/@paperbits/common/publishing/jsdomHtmlDocumentProvider.ts 4:16-32
@ ./node_modules/@paperbits/common/publishing/index.ts 27:13-51
@ ./node_modules/@paperbits/core/core.publish.module.ts 10:21-60
@ ./examples/publisher/azure-function/publish/index.ts 17:30-76

WARNING in ./node_modules/ws/lib/validation.js 122:24-49
Module not found: Error: Can't resolve 'utf-8-validate' in '...\node_modules\ws\lib'
@ ./node_modules/ws/lib/receiver.js 13:43-66
@ ./node_modules/ws/index.js 7:21-46
@ ./node_modules/jsdom/lib/jsdom/living/websockets/WebSocket-impl.js 7:18-31
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js 21:22-83
@ ./node_modules/jsdom/lib/api.js 13:25-61
@ ./node_modules/@paperbits/common/publishing/jsdomHtmlDocumentProvider.ts 4:16-32
@ ./node_modules/@paperbits/common/publishing/index.ts 27:13-51
@ ./node_modules/@paperbits/core/core.publish.module.ts 10:21-60
@ ./examples/publisher/azure-function/publish/index.ts 17:30-76

2 warnings have detailed information that is not shown.
Use 'stats.errorDetails: true' resp. '--stats-error-details' to show it.

ERROR in ./node_modules/jsdom/lib/jsdom/utils.js 154:2-27
Module not found: Error: Can't resolve 'canvas' in '...\node_modules\jsdom\lib\jsdom'
resolve 'canvas' in '...\node_modules\jsdom\lib\jsdom'
Parsed request is a module
using description file: ...\node_modules\jsdom\package.json (relative path: ./lib/jsdom)
resolve as module
...\node_modules\jsdom\lib\jsdom\node_modules doesn't exist or is not a directory
...\node_modules\jsdom\lib\node_modules doesn't exist or is not a directory
looking for modules in ...\node_modules\jsdom\node_modules
single file module
using description file: ...\node_modules\jsdom\package.json (relative path: ./node_modules/canvas)
no extension
...\node_modules\jsdom\node_modules\canvas doesn't exist
.ts
...\node_modules\jsdom\node_modules\canvas.ts doesn't exist
.tsx
...\node_modules\jsdom\node_modules\canvas.tsx doesn't exist
.js
...\node_modules\jsdom\node_modules\canvas.js doesn't exist
.jsx
...\node_modules\jsdom\node_modules\canvas.jsx doesn't exist
.html
...\node_modules\jsdom\node_modules\canvas.html doesn't exist
.scss
...\node_modules\jsdom\node_modules\canvas.scss doesn't exist
...\node_modules\jsdom\node_modules\canvas doesn't exist
...\node_modules\node_modules doesn't exist or is not a directory
looking for modules in ...\node_modules
single file module
using description file: ...\package.json (relative path: ./node_modules/canvas)
no extension
...\node_modules\canvas doesn't exist
.ts
...\node_modules\canvas.ts doesn't exist
.tsx
...\node_modules\canvas.tsx doesn't exist
.js
...\node_modules\canvas.js doesn't exist
.jsx
...\node_modules\canvas.jsx doesn't exist
.html
...\node_modules\canvas.html doesn't exist
.scss
...\node_modules\canvas.scss doesn't exist
...\node_modules\canvas doesn't exist
...\node_modules doesn't exist or is not a directory
C:\src\node_modules doesn't exist or is not a directory
C:\node_modules doesn't exist or is not a directory
@ ./node_modules/jsdom/lib/jsdom/browser/Window.js 8:26-45
@ ./node_modules/jsdom/lib/api.js 13:25-61
@ ./node_modules/@paperbits/common/publishing/jsdomHtmlDocumentProvider.ts 4:16-32
@ ./node_modules/@paperbits/common/publishing/index.ts 27:13-51
@ ./node_modules/@paperbits/core/core.publish.module.ts 10:21-60
@ ./examples/publisher/azure-function/publish/index.ts 17:30-76

webpack 5.76.1 compiled with 1 error and 2 warnings in 79595 ms`

Contributor guide

No contributing guide indexed for this repository

Research direction

Run npm run build-function and inspect the dependency path through examples/publisher/azure-function/publish/index.ts, @paperbits/common/publishing/jsdomHtmlDocumentProvider.ts, and jsdom's reported utils.js failure. Compare the canvas error with the bufferutil and utf-8-validate warnings; done means the command completes successfully without the optional canvas lookup failing the build.

Written by the indexing model from the issue text.

Assessment

Tech stack
nodejs, typescript, webpack
Domain
build-system, ci-cd
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.