3

我不断收到这些错误:

 ../src/public/AngularApp/cmsApp/boot.component.ts(4,27): error TS2307: Cannot find module '@angular/core'.
../src/public/AngularApp/main.ts(1,30): error TS2307: Cannot find module '@angular/platform-browser-dynamic'.
../src/server.ts(1,1): error TS6053: File '/LocalProjects/cmsApp/typings/index.d.ts' not found.
../src/server.ts(2,26): error TS2307: Cannot find module 'express'.
../src/server.ts(3,29): error TS2307: Cannot find module 'body-parser'.
../src/server.ts(4,31): error TS2307: Cannot find module 'errorhandler'.
../src/server.ts(5,33): error TS2307: Cannot find module 'method-override'.
../src/server/routes/index.ts(1,26): error TS2307: Cannot find module 'express'.
../src/server/routes/index.ts(2,23): error TS2307: Cannot find module 'path'.
../src/server/routes/index.ts(6,48): error TS2304: Cannot find name '__dirname'.

当我编译为 js 时。

js出来了,一切正常。我认为这与我对类型的引用有关。

我在我的server.ts文件中这样做了:

/// <reference path="../typings/index.d.ts" />

这是我的打字文件:

  "name": "typescript-express-seed",
  "dependecies": {},
  "globalDependencies": {
    "bluebird": "github:DefinitelyTyped/DefinitelyTyped/bluebird/bluebird.d.ts#e5a27ea95e47b95333784f1f0d590127b4e39a89",
    "body-parser": "github:DefinitelyTyped/DefinitelyTyped/body-parser/body-parser.d.ts#e5a27ea95e47b95333784f1f0d590127b4e39a89",
    "cors": "github:DefinitelyTyped/DefinitelyTyped/cors/cors.d.ts#11322524f8db9cdb921427cad84cd22fe2d4f965",
    "express": "github:DefinitelyTyped/DefinitelyTyped/express/express.d.ts#11322524f8db9cdb921427cad84cd22fe2d4f965",
    "express-jwt": "github:DefinitelyTyped/DefinitelyTyped/express-jwt/express-jwt.d.ts#2cb8fd4638231efd24929f99d56372bdb57d337b",
    "express-unless": "github:DefinitelyTyped/DefinitelyTyped/express-unless/express-unless.d.ts#b80f7caacfe2430b9e34d7fba1d262205c233ce9",
    "jsonwebtoken": "github:DefinitelyTyped/DefinitelyTyped/jsonwebtoken/jsonwebtoken.d.ts#8d9e2d7993a2ac7d38427bd08bee641251f2dfd4",
    "mime": "github:DefinitelyTyped/DefinitelyTyped/mime/mime.d.ts#11322524f8db9cdb921427cad84cd22fe2d4f965",
    "moment": "github:DefinitelyTyped/DefinitelyTyped/moment/moment.d.ts#7136728255d96038795d93c3e4b43c3c7de8ac1e",
    "moment-node": "github:DefinitelyTyped/DefinitelyTyped/moment/moment-node.d.ts#7136728255d96038795d93c3e4b43c3c7de8ac1e",
    "moment-timezone": "github:DefinitelyTyped/DefinitelyTyped/moment-timezone/moment-timezone.d.ts#7136728255d96038795d93c3e4b43c3c7de8ac1e",
    "mysql": "github:DefinitelyTyped/DefinitelyTyped/mysql/mysql.d.ts#8ac2edf817ab77a00f0d2a1a53bb46eb2a466067",
    "node": "github:DefinitelyTyped/DefinitelyTyped/node/node.d.ts#0d66537e353802f996a3f67ca1b711f63835f9e7",
    "serve-static": "github:DefinitelyTyped/DefinitelyTyped/serve-static/serve-static.d.ts#0fa4e9e61385646ea6a4cba2aef357353d2ce77f",
    "source-map-support": "github:DefinitelyTyped/DefinitelyTyped/source-map-support/source-map-support.d.ts#f8af639bf29b2b00e5d27ce93c0f046564b8525c"
  },
  "dependencies": {
    "debug": "registry:npm/debug#2.0.0+20160511151334"
  }

我做错了什么,如何解决它,以免出现编译错误?

也找不到 ref,但它与哪个文件相关?到 server.ts 或我的 gulpfile.js (编译器在哪里运行?)

文件夹结构:

APP
| gulp
    |-gulpfile.js
|
|typings
    |-index.d.ts
    |-globals
    |-modules
|typings.json
|
|src
    |-server.ts
4

0 回答 0