错误" ng serve"在cmd上

时间:2017-02-08 15:26:59

标签: javascript angular npm

当我输入cmd" ng serve"对于运行angular2,它出现错误:

"未知浏览器查询basedir = $(dirname $(echo $ 0 | sed -e s,\,/,g))"

  

未知的浏览器查询basedir=$(dirname "$(echo "$0" | sed -e 's,\\,/,g')")       BrowserslistError:未知的浏览器查询basedir=$(dirname "$(echo "$0" | sed - e 's,\\,/,g')")       出错(D:\ angular_node \ aaa \ node_modules \ browserslist \ index.js:37:11)       在D:\ angular_node \ aaa \ node_modules \ browserslist \ index.js:215:9       at Array.forEach(native)       在browserslist(D:\ angular_node \ aaa \ node_modules \ browserslist \ index.js:192:       13)       在cleanBrowsersList(D:\ angular_node \ aaa \ node_modules \ caniuse-api \ dist \ util       s.js:56:59)       在setBrowserScope(D:\ angular_node \ aaa \ node_modules \ caniuse-api \ dist \ index。       JS:30:43)       在对象。 (d:\ angular_node \ AAA \ node_modules \ caniuse-API \ DIST \ IND       ex.js:92:1)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \ postcss合并规则\       DIST \ lib中\ ensureCompatibility.js:7:19)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \ postcss合并规则\       DIST \ index.js:23:28)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \ cssnano \ DIST \ index.j       S:113:26)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \角CLI \模型\瓦特       ebpack-CONFIGS \ styles.js:6:15)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \角CLI \模型\瓦特       ebpack-CONFIGS \ index.js:8:10)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \角CLI \模型\瓦特       ebpack-config.js:4:25)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \角CLI \任务\本身       rve.js:11:24)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在对象。 (d:\ angular_node \ AAA \ node_modules \角CLI \命令       \ serve.run.js:6:15)       在Module._compile(module.js:570:32)       在Object.Module._extensions..js(module.js:579:10)       在Module.load(module.js:487:32)       在tryModuleLoad(module.js:446:12)       在Function.Module._load(module.js:438:3)       在Module.require(module.js:497:17)       at require(internal / module.js:20:19)       在Class.run(D:\ angular_node \ aaa \ node_modules \ angular-cli \ commands \ serve.js)       :67:16)       在课堂上。 (d:\ angular_node \ AAA \ node_modules \角CLI \余烬-CLI       \ LIB \型号\ command.js:134:17)       at process._tickCallback(internal / process / next_tick.js:103:7)

所以我在Google Globe周围搜索过,但一无所获。 谁能告诉我如何解决它???不管怎么说,还是要谢谢你... 注意:我在Windows 8 32位上运行

角cli.json



{
  "project": {
    "version": "1.0.0-beta.28.3",
    "name": "testing"
  },
  "apps": [
    {
      "root": "src",
      "outDir": "dist",
      "assets": [
        "assets",
        "favicon.ico"
      ],
      "index": "index.html",
      "main": "main.ts",
      "polyfills": "polyfills.ts",
      "test": "test.ts",
      "tsconfig": "tsconfig.json",
      "prefix": "app",
      "styles": [
        "styles.css"
      ],
      "scripts": [],
      "environments": {
        "source": "environments/environment.ts",
        "dev": "environments/environment.ts",
        "prod": "environments/environment.prod.ts"
      }
    }
  ],
  "e2e": {
    "protractor": {
      "config": "./protractor.conf.js"
    }
  },
  "lint": [
    {
      "files": "src/**/*.ts",
      "project": "src/tsconfig.json"
    },
    {
      "files": "e2e/**/*.ts",
      "project": "e2e/tsconfig.json"
    }
  ],
  "test": {
    "karma": {
      "config": "./karma.conf.js"
    }
  },
  "defaults": {
    "styleExt": "css",
    "prefixInterfaces": false,
    "inline": {
      "style": false,
      "template": false
    },
    "spec": {
      "class": false,
      "component": true,
      "directive": true,
      "module": false,
      "pipe": true,
      "service": true
    }
  }
}




的package.json



{
  "name": "testing",
  "version": "0.0.0",
  "license": "MIT",
  "angular-cli": {},
  "scripts": {
    "ng": "ng",
    "start": "ng serve",
    "test": "ng test",
    "pree2e": "webdriver-manager update --standalone false --gecko false",
    "e2e": "protractor"
  },
  "private": true,
  "dependencies": {
    "@angular/common": "^2.3.1",
    "@angular/compiler": "^2.3.1",
    "@angular/core": "^2.3.1",
    "@angular/forms": "^2.3.1",
    "@angular/http": "^2.3.1",
    "@angular/platform-browser": "^2.3.1",
    "@angular/platform-browser-dynamic": "^2.3.1",
    "@angular/router": "^3.3.1",
    "core-js": "^2.4.1",
    "rxjs": "^5.0.1",
    "ts-helpers": "^1.1.1",
    "zone.js": "^0.7.2"
  },
  "devDependencies": {
    "@angular/compiler-cli": "^2.3.1",
    "@types/jasmine": "2.5.38",
    "@types/node": "^6.0.42",
    "angular-cli": "1.0.0-beta.28.3",
    "codelyzer": "~2.0.0-beta.1",
    "jasmine-core": "2.5.2",
    "jasmine-spec-reporter": "2.5.0",
    "karma": "1.2.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.0.2",
    "karma-remap-istanbul": "^0.2.1",
    "protractor": "~4.0.13",
    "ts-node": "1.2.1",
    "tslint": "^4.3.0",
    "typescript": "~2.0.3"
  }
}




3 个答案:

答案 0 :(得分:5)

只需删除"浏览器列表" (文本文件)来自项目目录,同时也删除" browserlist.cmd"文件。 (它对我有用)

答案 1 :(得分:1)

我在Windows 10上遇到了与节点版本10.0.0和角度cli版本1.7.4相同的问题。现在删除了项目目录中的browserlists文件和browserslist.cmd。它对我有用:)。

答案 2 :(得分:0)

请参阅: https://github.com/angular/angular-cli/issues/3938#issuecomment-272633128

(更改文件名"浏览器列表"到" 00_browserslist"在项目文件夹中,为我修复了它)