模块未找到打字稿

时间:2017-07-10 14:22:52

标签: class validation typescript webpack babel

我想导入这个模块class validator,当我用webpack和babel编译我的应用程序时,我不知道为什么控制台显示这个错误:

ERROR in ./src/index.ts
Module not found: Error: Can't resolve 'class-validator' in '/****/***/projects/***/****/src'
 @ ./src/index.ts 30:24-50

我导入了这个模块:

import {Validator} from 'class-validator';

// Validation methods
const validator = new Validator();

class GlobalEntity{}
export default Global Entity;

我的tsconfig.json是:

{
  "compilerOptions": {
    "target": "es6",
    "allowSyntheticDefaultImports": true,
    "sourceMap": true,
    "allowJs": false,
    "declaration": true,
    "experimentalDecorators": true,
    "moduleResolution": "node",
    "lib": [ "es6", "dom" ],
    "outDir": "./dist",
    "module": "CommonJS"

  },
  "exclude": ["./node_modules","dist"],
  "files": ["./typings/index.d.ts", "./src/index.ts"]
}

有人能帮助我吗? 谢谢

亚历

0 个答案:

没有答案