无法找到' source-map'

时间:2018-02-19 02:39:32

标签: javascript angular visual-studio-code

我正在尝试运行一个角度5的应用程序,我从角度4升级但在运行npm run server:dev时遇到此错误:

[at-loader] Checking finished with 1 errors
[at-loader] TS2688: Cannot find type definition file for 'source-map'.

这是我的 package.json

    {
  "name": "Hidden",
  "version": "v1.0.0",
  "description": "",
  "keywords": [
    "Hidden"
  ],
  "author": "Hidden",
  "license": "MIT",
  "scripts": {
    "build:dev": "webpack --config config/webpack.dev.js --progress --profile",
    "build:docker": "npm run build:prod && docker build -t angular2-webpack-start:latest .",
    "build:prod": "webpack --config config/webpack.prod.js  --progress --profile --bail",
    "build": "npm run build:dev",
    "ci": "npm run lint && npm test && npm run e2e",
    "clean:dist": "npm run rimraf -- dist",
    "clean:install": "npm set progress=false && npm install",
    "clean:start": "npm start",
    "clean": "npm cache clean && npm run rimraf -- node_modules doc coverage dist",
    "docker": "docker",
    "docs": "npm run typedoc -- --options typedoc.json --exclude '**/*.spec.ts' ./src/",
    "e2e:live": "npm run e2e -- --elementExplorer",
    "e2e": "npm run protractor",
    "github-deploy:dev": "webpack --config config/webpack.github-deploy.js --progress --profile --github-dev",
    "github-deploy:prod": "webpack --config config/webpack.github-deploy.js --progress --profile --github-prod",
    "github-deploy": "npm run github-deploy:dev",
    "lint": "npm run tslint \"src/**/*.ts\"",
    "lite": "lite-server",
    "postversion": "git push && git push --tags",
    "prebuild:dev": "npm run clean:dist",
    "prebuild:prod": "npm run clean:dist",
    "preclean:install": "npm run clean",
    "preclean:start": "npm run clean",
    "pree2e": "npm run webdriver:update -- --standalone",
    "preversion": "npm test",
    "protractor": "protractor",
    "rimraf": "rimraf",
    "server:dev:hmr": "npm run server:dev -- --inline --hot",
    "server:dev": "webpack-dev-server --config config/webpack.dev.js --progress --profile --watch --content-base src/",
    "server:prod": "http-server dist --cors",
    "server": "npm run server:dev",
    "start:hmr": "npm run server:dev:hmr",
    "start": "npm run server:dev",
    "test": "karma start",
    "tslint": "tslint",
    "typedoc": "typedoc",
    "version": "npm run build",
    "watch:dev:hmr": "npm run watch:dev -- --hot",
    "watch:dev": "npm run build:dev -- --watch",
    "watch:prod": "npm run build:prod -- --watch",
    "watch:test": "npm run test -- --auto-watch --no-single-run",
    "watch": "npm run watch:dev",
    "webdriver-manager": "webdriver-manager",
    "webdriver:start": "npm run webdriver-manager start",
    "webdriver:update": "npm run webdriver-manager update",
    "webpack-dev-server": "webpack-dev-server",
    "webpack": "webpack"
  },
  "dependencies": {
    "@angular/animations": "^5.2.3",
    "@angular/common": "^5.2.3",
    "@angular/compiler": "^5.2.3",
    "@angular/core": "^5.2.3",
    "@angular/forms": "^5.2.3",
    "@angular/http": "^5.2.3",
    "@angular/material": "^2.0.0-beta.12",
    "@angular/platform-browser": "^5.2.3",
    "@angular/platform-browser-dynamic": "^5.2.3",
    "@angular/platform-server": "^5.2.3",
    "@angular/router": "^5.2.3",
    "@angularclass/conventions-loader": "^1.0.2",
    "@angularclass/hmr": "~2.1.3",
    "@angularclass/hmr-loader": "~3.0.4",
    "@ngtools/webpack": "^1.9.7",
    "@types/jquery": "^3.2.18",
    "angular-tag-cloud-module": "^2.4.0",
    "assets-webpack-plugin": "^3.4.0",
    "b64-to-blob": "^1.2.19",
    "core-js": "^2.4.1",
    "http-server": "^0.9.0",
    "ie-shim": "^0.1.0",
    "jquery": "^3.2.1",
    "ng2-bs3-modal": "^0.13.0",
    "ng2-img-cropper": "^0.9.0",
    "ngc-webpack": "^4.1.2",
    "occurences": "^2.2.2",
    "reflect-metadata": "^0.1.10",
    "rxjs": "^5.5.6",
    "zone.js": "~0.8.14"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^5.2.3",
    "@types/hammerjs": "^2.0.34",
    "@types/jasmine": "2.5.45",
    "@types/node": "^7.0.39",
    "@types/selenium-webdriver": "2.53.38",
    "@types/source-map": "^0.5.0",
    "@types/uglify-js": "^2.6.28",
    "@types/webpack": "^2.2.16",
    "angular2-template-loader": "^0.6.2",
    "assets-webpack-plugin": "^3.5.1",
    "awesome-typescript-loader": "~3.1.2",
    "codelyzer": "~2.1.1",
    "copy-webpack-plugin": "^4.0.1",
    "css-loader": "^0.28.0",
    "exports-loader": "^0.6.4",
    "expose-loader": "^0.7.3",
    "extract-text-webpack-plugin": "~3.0.0",
    "file-loader": "^0.11.1",
    "gh-pages": "^1.0.0",
    "html-webpack-plugin": "^2.28.0",
    "imports-loader": "^0.7.1",
    "istanbul-instrumenter-loader": "2.0.0",
    "jasmine-core": "^2.5.2",
    "json-loader": "^0.5.4",
    "karma": "^1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-coverage": "^1.1.1",
    "karma-jasmine": "^1.0.2",
    "karma-mocha-reporter": "^2.0.0",
    "karma-remap-coverage": "^0.1.4",
    "karma-sourcemap-loader": "^0.3.7",
    "karma-webpack": "1.8.1",
    "ng-router-loader": "^2.1.0",
    "node-sass": "^4.5.2",
    "npm-run-all": "^4.0.2",
    "parse5": "^3.0.2",
    "protractor": "^4.0.10",
    "raw-loader": "0.5.1",
    "rimraf": "~2.6.1",
    "sass-loader": "^6.0.3",
    "script-ext-html-webpack-plugin": "^1.8.5",
    "source-map-loader": "^0.2.1",
    "string-replace-loader": "~1.3.0",
    "strip-loader": "^0.1.2",
    "style-loader": "^0.18.1",
    "to-string-loader": "^1.1.5",
    "ts-helpers": "1.1.2",
    "ts-node": "^3.3.0",
    "tslint": "~4.5.1",
    "typedoc": "^0.7.1",
    "typescript": "2.4.2",
    "url-loader": "^0.5.8",
    "v8-lazy-parse-webpack-plugin": "^0.3.0",
    "webpack": "3.5.5",
    "webpack-dev-middleware": "^1.10.1",
    "webpack-dev-server": "~2.7.1",
    "webpack-md5-hash": "^0.0.5",
    "webpack-merge": "~4.1.0"
  },
  "engines": {
    "node": ">= 4.2.1",
    "npm": ">= 3"
  }
}

2 个答案:

答案 0 :(得分:7)

最后,我解决了这个问题。

我按照以下步骤操作:

  1. @types/source-map": "0.5.0
  2. 在package.json中,我添加了npm install请注意,我特别指定了版本0.5.0
  3. rails g migration add_slug_to_articles slug:string:uniq

答案 1 :(得分:0)

使用终端

中的ctrl + c停止应用程序

预先检查:

  1. 检查项目文件夹是否包含.angular-cli.json文件。如果不是,你必须创建它。

  2. 同时确保没有其他文件开头。角度cli。如果有,请删除它。

  3. 如果您仍然遇到错误,请使用ng new app-name创建新项目。创建后,复制package.json和.angular-cli.json文件并将其粘贴到您的文件夹中

  4. 请试试这个package.json。看起来你从Angular 2到Angular 4的迁移仍然使用旧的提供应用程序的方法

    {
      "name": "Hidden",
      "version": "0.0.0",
      "license": "MIT",
      "scripts": {
        "ng": "ng",
        "start": "ng serve",
        "build": "ng build",
        "test": "ng test",
        "start-mock-test-app": "ng serve -env=mock-test",
        "lint": "ng lint",
        "e2e": "ng e2e"
      },
      "private": true,
      "dependencies": {
        "@angular-devkit/core": "0.0.29",
        "@angular-devkit/schematics": "0.0.52",
        "@angular/animations": "^4.4.6",
        "@angular/common": "^4.4.6",
        "@angular/compiler": "^4.4.6",
        "@angular/core": "^4.4.6",
        "@angular/forms": "^4.4.6",
        "@angular/http": "^4.4.6",
        "@angular/platform-browser": "^4.4.6",
        "@angular/platform-browser-dynamic": "^4.4.6",
        "@angular/router": "^4.4.6",
        "@ngrx/effects": "^4.0.5",
        "@ngrx/router-store": "^4.0.4",
        "@ngrx/store": "^4.0.3",
        "@ngrx/store-devtools": "^4.0.0",
        "@types/source-map": "0.5.0",
        "body-parser": "^1.18.2",
        "bootstrap": "4.0.0-beta.2",
        "chai": "^3.5.0",
        "core-js": "^2.4.1",
        "cucumber": "^2.3.0",
        "express": "^4.16.1",
        "font-awesome": "^4.7.0",
        "forever-monitor": "^1.7.1",
        "minimist": "^1.2.0",
        "mkdirp": "^0.5.1",
        "primeng": "^4.3.0",
        "protractor": "^5.3.0",
        "protractor-cucumber-framework": "^4.1.1",
        "rxjs": "^5.4.2",
        "source-map": "^0.7.1", //
        "typescript": "^2.3.4",
        "zone.js": "^0.8.14"
      },
      "devDependencies": {
        "@angular/cli": "1.5.4",
        "@angular/compiler-cli": "^4.4.6",
        "@angular/language-service": "^4.4.6",
        "@types/jasmine": "~2.5.53",
        "@types/jasminewd2": "~2.0.2",
        "@types/node": "~6.0.60",
        "@types/cucumber": "0.0.38",
        "codelyzer": "~3.1.1",
        "jasmine-core": "~2.6.2",
        "jasmine-spec-reporter": "~4.1.0",
        "karma": "~1.7.0",
        "karma-chrome-launcher": "~2.1.1",
        "karma-cli": "~1.0.1",
        "karma-coverage-istanbul-reporter": "^1.2.1",
        "karma-jasmine": "~1.1.0",
        "karma-jasmine-html-reporter": "^0.2.2",
        "ngrx-store-freeze": "^0.2.0",
        "ts-node": "~3.2.0",
        "tslint": "~5.3.2",
        "typescript": "~2.5.3",
        "chai-as-promised": "^6.0.0",
        "cucumber-html-reporter": "^0.5.2"
      }
    }
    

    注意:在package.json中添加了"@types/source-map": "0.5.0","source-map": "^0.7.1",

    添加完毕后,请运行npm install,然后尝试使用ng serve

    投放

    希望它能够运作