![tensorflowjs 模块无法正确编译](https://linux22.com/image/1588439/tensorflowjs%20%E6%A8%A1%E5%9D%97%E6%97%A0%E6%B3%95%E6%AD%A3%E7%A1%AE%E7%BC%96%E8%AF%91.png)
$ npm show @tensorflow/tfjs version
$ 1.0.0
$ npm show typescript version
$ 3.4.3
当我编译项目时ng serve
,总是出现以下错误:
ERROR in node_modules/@tensorflow/tfjs-
core/dist/io/browser_files.d.ts(24,34): error TS1039: Initializers are not
allowed in ambient contexts.
node_modules/@tensorflow/tfjs-core/dist/io/browser_http.d.ts(23,31): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-core/dist/io/indexed_db.d.ts(31,34): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-core/dist/io/local_storage.d.ts(41,34): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-data/dist/dataset.d.ts(235,39): error TS1039:
Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(29,33): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(48,33): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(56,33): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(64,33): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(69,33): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(77,33): error
TS1039: Initializers are not allowed in ambient contexts.
node_modules/@tensorflow/tfjs-layers/dist/activations.d.ts(85,33): error
TS1039: Initializers are not allowed in ambient contexts.
为什么还有另一个tensorflow
模块:
$npm show tensorflow version
$0.7.0
答案1
我遇到了同样的问题。我相信这是 tensorflowjs 最新版本的问题。我使用以下版本可以正常工作。
"@tensorflow-models/coco-ssd": "0.1.1",
"@tensorflow/tfjs": "0.14.0",
"rxjs": "6.0.0",
"typescript": "~2.7.2"