私はangle2プロジェクトでサードパーティライブラリをインポートする必要があります。ここでサードパーティのライブラリをインポート
は私がやったことです:
ng new myproject
npm install --save createjs-easeljs
npm install @types/easeljs
は、今私はこだわっています瞬間です。このライブラリをどのようにインポートして使用しますか?これは、まったく動作しないShape
またはStage
import { Shape, Stage } from '../../../node_modules/createjs-easeljs/lib/easeljs-0.8.2.min.js';
のようなオブジェクトがあります。
マイフォルダ構造:あなたのtsconfig.json
へのパス(とbaseUrl
)を追加する必要が
dynam194:src timo$ tree -L 2
.
├── app
│ ├── app.component.css
│ ├── app.component.html
│ ├── app.component.spec.ts
│ ├── app.component.ts
│ ├── app.module.ts
│ └── canvas
├── assets
├── environments
│ ├── environment.prod.ts
│ └── environment.ts
├── favicon.ico
├── index.html
├── main.ts
├── polyfills.ts
├── styles.css
├── test.ts
├── tsconfig.json
└── typings
└── easeljs.d.ts
tsconfig.json
"paths": {
"easeljs": ["../node_modules/createjs-easeljs/lib/easeljs-0.8.2.min.js"]
},
"sourceMap": true,
"target": "es5",
"typeRoots": [
"../node_modules/@types",
"typings",
]
モジュールビルドに失敗しました:エラー:/myproject/src/app/canvas/canvas.component.ts(2,27):ファイル '/ myproject/node_modules /@types/easeljs/index.d.ts 'はモジュールではありません。) 'ここで2,27はあなたが書き込んだインポートです。 – tuna
これは '@ types'の厄介な特性です。私は答えを更新しました – PierreDuc
うーん、動作していないようです。同じエラー。私の入力経路は '。/ typings'です。また、refパスを '... @ types/easeljs/index.d.ts ... 'に変更しました。 createjs/easeljsという名前の問題でしょうか? – tuna