I followed How can I use JointJS with an application built with Angular CLI? to install JointJS on Angular. Anyway I have this problem when I start the project:
Module not found: Error: Can't resolve './node_modules/jointjs/dist/joint.js'
I tried to change this import
const joint = require('./node_modules/jointjs/dist/joint.js');
with this: import * as joint from 'jointjs/dist/joint';
In this way I have no problem when I start the project but I cannot use this type of method let m1 = new joint.shapes.devs.Model
because I have this error:
TS2339:Property 'devs' does not exist on type 'typeof shapes'
With methods like this: let rect2 = new joint.shapes.basic.Rect
or this let link = new joint.dia.Link
I have no problems. I think that is an import problem.
This is my angular-cli.json:
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"project": {
"version": "1.0.0-beta.32.3",
"name": "jointangular"
},
"apps": [
{
"root": "src",
"outDir": "dist",
"assets": [
"assets",
"favicon.ico"
],
"index": "index.html",
"main": "main.ts",
"polyfills": "polyfills.ts",
"test": "test.ts",
"tsconfig": "tsconfig.json",
"prefix": "app",
"styles": [
"styles.css",
"../node_modules/jointjs/css/layout.css"
],
"scripts": [
"../node_modules/jquery/dist/jquery.min.js",
"../node_modules/jointjs/dist/joint.js"
],
"environmentSource": "environments/environment.ts",
"environments": {
"dev": "environments/environment.ts",
"prod": "environments/environment.prod.ts"
}
}
],
"e2e": {
"protractor": {
"config": "./protractor.conf.js"
}
},
"lint": [
{
"files": "src/**/*.ts",
"project": "src/tsconfig.json"
},
{
"files": "e2e/**/*.ts",
"project": "e2e/tsconfig.json"
}
],
"test": {
"karma": {
"config": "./karma.conf.js"
}
},
"defaults": {
"styleExt": "css",
"component": {}
}
}
my package.json:
{
"name": "jointangular",
"version": "0.0.0",
"license": "MIT",
"angular-cli": {},
"scripts": {
"ng": "ng",
"start": "ng serve",
"test": "ng test",
"lint": "ng lint",
"e2e": "ng e2e"
},
"private": true,
"dependencies": {
"@angular/common": "^2.4.0",
"@angular/compiler": "^2.4.0",
"@angular/core": "^2.4.0",
"@angular/forms": "^2.4.0",
"@angular/http": "^2.4.0",
"@angular/platform-browser": "^2.4.0",
"@angular/platform-browser-dynamic": "^2.4.0",
"@angular/router": "^3.4.0",
"@types/jquery": "^2.0.40",
"core-js": "^2.4.1",
"jointjs": "^1.0.3",
"jquery": "^3.1.1",
"rxjs": "^5.1.0",
"zone.js": "^0.7.6"
},
"devDependencies": {
"@angular/cli": "1.0.0-beta.32.3",
"@angular/compiler-cli": "^2.4.0",
"@types/backbone": "^1.3.33",
"@types/jasmine": "2.5.38",
"@types/jointjs": "^1.0.3",
"@types/lodash": "^3.10.1",
"@types/node": "~6.0.60",
"backbone": "^1.3.3",
"codelyzer": "~2.0.0-beta.4",
"install": "^0.8.9",
"jasmine-core": "~2.5.2",
"jasmine-spec-reporter": "~3.2.0",
"karma": "~1.4.1",
"karma-chrome-launcher": "~2.0.0",
"karma-cli": "~1.0.1",
"karma-coverage-istanbul-reporter": "^0.2.0",
"karma-jasmine": "~1.1.0",
"karma-jasmine-html-reporter": "^0.2.2",
"lodash": "^3.10.1",
"npm": "^4.5.0",
"protractor": "~5.1.0",
"ts-node": "~2.0.0",
"tslint": "~4.4.2",
"typescript": "~2.0.0"
}
}
Do you have any ideas?