【发布时间】:2020-01-02 05:06:52
【问题描述】:
index.ts
import { Engine } from '@babylonjs/core/Engine/engine';
[tsl] ERROR in ~/Documents/babylon1/src/index.ts(1,24)
TS2307: Cannot find module '@babylonjs/core/Engines/engine'.
我已按照 Babylon 文档页面上的步骤以及https://doc.babylonjs.com/features/npm_support#error-ts2307-cannot-find-module-babylonjs-or-other-modules 的故障排除说明进行操作。我在 tscong.json 中添加了“babylonjs”,但我仍然收到“找不到模块 @babylonjs/core”错误。
package.json
"devDependencies": {
"@babylonjs/core": "^4.0.3",
"ts-loader": "^6.2.1",
"typescript": "^3.7.4",
"webpack": "^4.41.5",
"webpack-cli": "^3.3.10",
"webpack-dev-server": "^3.10.1"
},
"dependencies": {
"babylonjs": "^4.0.3"
}
tsconfig.json
{
"compilerOptions": {
"outDir": "./dist",
"sourceMap": true,
"noImplicitAny": true,
"strictNullChecks": false,
"module": "es6",
"target": "es6",
"types": [
"babylonjs"
]
}
}
我使用npm install 只是为了确保没有遗漏任何东西。
【问题讨论】:
-
我通过
npm install -D @types/babylonjs编译它,并将import更改为babylonjs。这并不理想,因为它导入了整个 2.5MB 库,而不是单个模块,但它可以工作。
标签: babylonjs