首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >编译节点模块时的类型记录错误

编译节点模块时的类型记录错误
EN

Stack Overflow用户
提问于 2017-11-08 02:04:09
回答 2查看 8.3K关注 0票数 4

我下载了打字稿,速递,续写,邮政示例,运行了npm installnpm start

npm start上,它产生了一些错误。

代码语言:javascript
复制
[11:27:11] Starting 'compile:typescript'...
~/node_modules/@types/geojson/index.d.ts(94,54): error TS1005: ',' expected.
~/node_modules/@types/geojson/index.d.ts(104,64): error TS1005: ',' expected.
~/node_modules/@types/handlebars/index.d.ts(22,31): error TS1005: ',' expected.
~/node_modules/@types/handlebars/index.d.ts(24,32): error TS1005: ',' expected.
~/node_modules/@types/handlebars/index.d.ts(99,40): error TS1005: ',' expected.
~/node_modules/@types/express-validator/index.d.ts(23,2): error TS2300: Duplicate identifier 'export='.
~/node_modules/@types/express-validator/index.d.ts(37,28): error TS2374: Duplicate string index signature.
~/node_modules/@types/geojson/index.d.ts(94,56): error TS2368: Type parameter name cannot be 'any'
~/node_modules/@types/geojson/index.d.ts(104,66): error TS2368: Type parameter name cannot be 'any'
~/node_modules/@types/geojson/index.d.ts(106,21): error TS2314: Generic type 'Feature<G, P, any>' requires 3 type argument(s).
~/node_modules/@types/handlebars/index.d.ts(22,33): error TS2368: Type parameter name cannot be 'any'
~/node_modules/@types/handlebars/index.d.ts(22,77): error TS2314: Generic type 'HandlebarsTemplateDelegate<T, any>' requires 2 type argument(s).
~/node_modules/@types/handlebars/index.d.ts(24,34): error TS2368: Type parameter name cannot be 'any'
~/node_modules/@types/handlebars/index.d.ts(24,79): error TS2314: Generic type 'HandlebarsTemplateDelegate<T, any>' requires 2 type argument(s).
~/node_modules/@types/handlebars/index.d.ts(96,15): error TS2314: Generic type 'HandlebarsTemplateDelegate<T, any>' requires 2 type argument(s).
~/node_modules/@types/handlebars/index.d.ts(99,42): error TS2368: Type parameter name cannot be 'any'
~/node_modules/@types/handlebars/index.d.ts(104,22): error TS2314: Generic type 'HandlebarsTemplateDelegate<T, any>' requires 2 type argument(s).
~/node_modules/@types/handlebars/index.d.ts(115,34): error TS2314: Generic type 'HandlebarsTemplateDelegate<T, any>' requires 2 type argument(s).
~/node_modules/express-validator/index.d.ts(24,3): error TS2300: Duplicate identifier 'export='.
src/server.ts(6,35): error TS2497: Module '"express-validator"' resolves to a non-module entity and cannot be imported using this construct.
[11:27:13] TypeScript: 5 syntax errors
[11:27:13] TypeScript: 15 semantic errors

package.json

代码语言:javascript
复制
{
  "main": "build/src/server.js",
  "scripts": {
    "build": "gulp build",
    "doc": "gulp generate:doc",
    "start": "cross-env NODE_ENV=development gulp watch",
    "start:prod": "cross-env NODE_ENV=production gulp watch",
    "run:test": "cross-env NODE_ENV=test gulp test",
    "tslint": "gulp tslint",
    "precommit": "lint-staged",
    "prettify": "tsfmt -r --baseDir ./src",
    "sqlz:migrate": "./node_modules/.bin/sequelize db:migrate",
    "sqlz:undo": "./node_modules/.bin/sequelize db:migrate:undo",
    "sqlz:new": "./node_modules/.bin/sequelize migration:create"
  },
  "lint-staged": {
    "src/**/*.ts": [
      "prettify",
      "git add"
    ]
  },
  "dependencies": {
    "body-parser": "~1.17.0",
    "cors": "~2.8.1",
    "cross-env": "~3.2.3",
    "express": "~4.15.0",
    "express-boom": "~2.0.0",
    "express-validator": "^3.1.3",
    "morgan": "~1.8.1",
    "pg": "~6.1.2",
    "pg-hstore": "~2.3.2",
    "sequelize": "~3.30.2",
    "uuid": "~3.0.1",
    "winston": "~2.3.1"
  },
  "devDependencies": {
    "@types/body-parser": "~0.0.33",
    "@types/chai": "~3.4.35",
    "@types/express": "~4.0.35",
    "@types/express-validator": "~2.20.33",
    "@types/mocha": "~2.2.39",
    "@types/morgan": "~1.7.32",
    "@types/sequelize": "~3.4.40",
    "@types/winston": "~2.2.0",
    "chai": "~3.5.0",
    "extendify": "~1.0.0",
    "glob": "~7.1.1",
    "gulp": "~3.9.1",
    "gulp-istanbul": "~1.1.1",
    "gulp-json-refs": "~0.1.1",
    "gulp-mocha": "~3.0.1",
    "gulp-nodemon": "~2.2.1",
    "gulp-plumber": "~1.1.0",
    "gulp-sourcemaps": "~2.4.0",
    "gulp-tslint": "~7.0.1",
    "gulp-typedoc": "~2.0.2",
    "gulp-typescript": "~3.1.4",
    "husky": "^0.13.2",
    "lint-staged": "^3.4.0",
    "remap-istanbul": "~0.8.4",
    "rimraf": "~2.5.4",
    "run-sequence": "~1.2.2",
    "sequelize-cli": "^2.7.0",
    "tslint": "~4.5.1",
    "typedoc": "~0.5.7",
    "typescript": "~2.2.1",
    "typescript-formatter": "^5.1.1"
  },
  "engines": {
    "node": ">=4.0.0"
  },
}

gulpfile.js(Error相关部分)

代码语言:javascript
复制
...
let gulp = require("gulp");
let sourcemaps = require("gulp-sourcemaps");
...
const COMPILE_TYPESCRIPT = "compile:typescript";
const JS_SRC_GLOB = "./build/**/*.js";
const TS_GLOB = [TS_SRC_GLOB];
const tsProject = typescript.createProject("tsconfig.json");
...
gulp.task(COMPILE_TYPESCRIPT, function() {
    return gulp.src(TS_GLOB)
        .pipe(sourcemaps.init())
        .pipe(tsProject())
        .pipe(sourcemaps.write(".", { sourceRoot: "../src" }))
        .pipe(gulp.dest("build"));
});

tsconfig.json

代码语言:javascript
复制
{
  "compilerOptions": {
    "target": "es6",
    "module": "commonjs",
    "declaration": false,
    "noImplicitAny": false,
    "removeComments": true,
    "noLib": false,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "sourceMap": true
  },
  "exclude": [
    "node_modules"
  ]
}

为了解决这个问题,我看到了这个这篇文章,没有意义在这篇文章"files"属性中包含什么。

如何纠正此错误?有没有人遇到过这样的错误?

谢谢你的任何帮助。

EN

回答 2

Stack Overflow用户

回答已采纳

发布于 2017-11-10 09:00:03

我删除了所有节点模块,并在运行npm start时一个接一个地添加了错误的内容。

下面是更新的节点模块。

代码语言:javascript
复制
"dependencies": {
    "body-parser": "^1.17.1",
    "boom": "^7.1.1",
    "cookie-parser": "^1.4.3",
    "cors": "^2.8.4",
    "cross-env": "^5.1.1",
    "express": "^4.15.2",
    "express-boom": "^2.0.0",
    "express-validator": "^4.3.0",
    "gulp": "^3.9.1",
    "gulp-istanbul": "^1.1.2",
    "gulp-mocha": "^4.3.1",
    "gulp-nodemon": "^2.2.1",
    "gulp-plumber": "^1.1.0",
    "gulp-sourcemaps": "^2.6.1",
    "gulp-tslint": "^8.1.2",
    "gulp-typedoc": "^2.1.1",
    "gulp-typescript": "^3.2.3",
    "morgan": "^1.8.1",
    "nodemon": "^1.12.1",
    "pg": "^6.4.1",
    "postgresql": "0.0.1",
    "pug": "^2.0.0-beta11",
    "reflect-metadata": "^0.1.10",
    "remap-istanbul": "^0.9.5",
    "rimraf": "^2.6.2",
    "run-sequence": "^2.2.0",
    "sequelize": "^3.21.0",
    "sequelize-cli": "^3.0.0",
    "sequelize-typescript": "^0.5.0",
    "serve-favicon": "^2.4.1",
    "tslint": "^5.8.0",
    "typedoc": "^0.9.0",
    "typescript": "^2.6.1",
    "uuid": "^3.1.0",
    "winston": "^2.4.0"
  },
  "devDependencies": {
    "@types/body-parser": "1.16.1",
    "@types/cookie-parser": "^1.3.30",
    "@types/ejs": "^2.3.33",
    "@types/express": "^4.0.35",
    "@types/morgan": "^1.7.32",
    "@types/node": "^7.0.10",
    "@types/serve-favicon": "^2.2.28"
  }
票数 0
EN

Stack Overflow用户

发布于 2017-11-08 06:23:22

尝尝这个。

代码语言:javascript
复制
"exclude": [
    "node_modules/*"
]
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/47170389

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档