paperjs / paper.js

The Swiss Army Knife of Vector Graphics Scripting – Scriptographer ported to JavaScript and the browser, using HTML5 Canvas. Created by @lehni & @puckey
http://paperjs.org
Other
14.46k stars 1.22k forks source link

Error trying to build server side rendering angular 9 #1904

Open ozaytunctan opened 3 years ago

ozaytunctan commented 3 years ago

I got the same error and a few more when using paper 0.12.0 . The server folder is not generated when the build part of the distribution kit for server rendering is build. The commands that I ran:

ng add @ nguniversal / express-engine
npm run build: ssr && npm run serve: ssr

Exceptions and warnings:

WARNING in ./node_modules/paper/dist/node/extend.js 29:8-15
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./node_modules/paper/dist/node/extend.js 48:32-39
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./node_modules/paper/dist/node/canvas.js
Module not found: Error: Can't resolve 'canvas' in '/home/ubuntudev/workspace/dev/repos/client/btxclient/node_modules/paper/dist/node'

ERROR in ./node_modules/jsdom/lib/jsdom/utils.js
Module not found: Error: Can't resolve 'canvas' in '/home/ubuntudev/workspace/dev/repos/client/btxclient/node_modules/jsdom/lib/jsdom'

package.json

{ "name": "btxclient", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e", "dev:ssr": "ng run btxclient:serve-ssr", "serve:ssr": "node dist/btxclient/server/main.js", "build:ssr": "ng build --prod && ng run btxclient:server:production", "prerender": "ng run btxclient:prerender" }, "private": true, "dependencies": { "@angular/animations": "^9.0.7", "@angular/cdk": "^9.1.3", "@angular/common": "~9.0.7", "@angular/compiler": "~9.0.7", "@angular/core": "~9.0.7", "@angular/flex-layout": "^9.0.0-beta.29", "@angular/forms": "~9.0.7", "@angular/material": "^9.1.3", "@angular/platform-browser": "~9.0.7", "@angular/platform-browser-dynamic": "~9.0.7", "@angular/platform-server": "~9.0.7", "@angular/router": "~9.0.7", "@nguniversal/express-engine": "^9.0.2", "@ngx-translate/core": "^12.1.2", "@ngx-translate/http-loader": "^4.0.0", "@types/jquery": "^3.5.5", "express": "^4.15.2", "jquery": "^3.5.1", "net": "^1.0.2", "ng-pick-datetime": "^7.0.0", "ngx-mask": "^9.1.2", "ngx-mat-select-search": "^3.1.4", "ngx-toastr": "^12.0.1", "ngx-translate-multi-http-loader": "^3.0.0", "paper": "^0.12.11", "rxjs": "~6.5.4", "sockjs-client": "^1.4.0", "stompjs": "^2.3.3", "swiper": "^6.1.2", "tslib": "^1.10.0", "uuid": "^8.1.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.900.7", "@angular/cli": "~9.0.7", "@angular/compiler-cli": "~9.0.7", "@angular/language-service": "~9.0.7", "@nguniversal/builders": "^9.0.2", "@types/express": "^4.17.0", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "@types/node": "^12.11.1", "codelyzer": "^5.1.2", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "node-sass": "^4.13.1", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.7.5" } }

sapics commented 3 years ago

This comment copy from #1912 which is @ozaytunctan created

I got the same error and a few more when using paper 0.12.0 . The server folder is not generated when the build part of the distribution kit for server rendering is build. The commands that I ran:

ng add @ nguniversal / express-engine
npm run build: ssr && npm run serve: ssr

Exceptions and warnings:

WARNING in ./node_modules/paper/dist/node/extend.js 29:8-15
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./node_modules/paper/dist/node/extend.js 48:32-39
Critical dependency: require function is used in a way in which dependencies cannot be statically extracted

WARNING in ./node_modules/paper/dist/node/canvas.js
Module not found: Error: Can't resolve 'canvas' in '/home/ubuntudev/workspace/dev/repos/client/btxclient/node_modules/paper/dist/node'

ERROR in ./node_modules/jsdom/lib/jsdom/utils.js
Module not found: Error: Can't resolve 'canvas' in '/home/ubuntudev/workspace/dev/repos/client/btxclient/node_modules/jsdom/lib/jsdom'
lenargum commented 2 years ago

I have almost the same issue on Vue 2, Nuxt 2 (paper is 0.12.15) in paper/dist/node/extend.js:29:

TypeError
Cannot set properties of undefined (setting '.pjs')

require.extension is undefined