遇到npm的问题运行国际化

时间:2018-01-24 08:56:45

标签: angular npm

的package.json

{
  "name": "m.zbor.md",
  "version": "1.0.0",
  "description": "Versiunea Mobila Saitului Zbor.md",
  "scripts": {
    "build": "tsc -p src/",
    "build:watch": "tsc -p src/ -w",
    "build:e2e": "tsc -p e2e/",
    "serve": "lite-server -c=bs-config.json",
    "serve:e2e": "lite-server -c=bs-config.e2e.json",
    "prestart": "npm run build",
    "start": "concurrently \"npm run build:watch\" \"npm run serve\"",
    "pree2e": "npm run build:e2e",
    "e2e": "concurrently \"npm run serve:e2e\" \"npm run protractor\" --kill-others --success first",
    "preprotractor": "webdriver-manager update",
    "protractor": "protractor protractor.config.js",
    "pretest": "npm run build",
    "test": "concurrently \"npm run build:watch\" \"karma start karma.conf.js\"",
    "pretest:once": "npm run build",
    "test:once": "karma start karma.conf.js --single-run",
    "lint": "tslint ./src/**/*.ts -t verbose",
    "internationalize": "ng-xi18n -p tsconfig.json"
  },
  "keywords": [],
  "author": "",
  "license": "MIT",
  "dependencies": {
    "@angular-devkit/core": "0.0.28",
    "@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/platform-server": "^5.2.1",
    "@angular/router": "^4.4.6",
    "@angular/upgrade": "^4.4.6",
    "@schematics/angular": "^0.1.16",
    "angular-in-memory-web-api": "~0.3.0",
    "angular2-bootstrap-switch": "^0.2.3",
    "angular2-in-memory-web-api": "0.0.21",
    "bootstrap": "~4.0.0-beta.2",
    "core-js": "^2.5.2",
    "html-minifier": "^3.5.7",
    "moment": "^2.19.4",
    "mydatepicker": "^2.6.1",
    "mydaterangepicker": "^4.1.12",
    "ngx-bootstrap": "^2.0.0-beta.11",
    "reflect-metadata": "^0.1.10",
    "rxjs": "5.0.1",
    "systemjs": "0.19.40",
    "zone.js": "^0.8.4"
  },
  "devDependencies": {
    "@angular/cli": "^1.6.0",
    "@angular/compiler-cli": "^4.4.6",
    "@types/jasmine": "2.5.36",
    "@types/node": "^6.0.92",
    "canonical-path": "0.0.2",
    "concurrently": "^3.5.1",
    "jasmine-core": "~2.4.1",
    "karma": "^1.3.0",
    "karma-chrome-launcher": "^2.0.0",
    "karma-cli": "^1.0.1",
    "karma-jasmine": "^1.1.1",
    "karma-jasmine-html-reporter": "^0.2.2",
    "lite-server": "^2.2.2",
    "lodash": "^4.16.4",
    "protractor": "~4.0.14",
    "rimraf": "^2.5.4",
    "tslint": "^3.15.1",
    "typescript": "~2.1.0"
  },
  "repository": {}
}

tsconfig.json

{
  "compilerOptions": {
    "target": "es5",
    "module": "commonjs",
    "moduleResolution": "node",
    "sourceMap": true,
    "emitDecoratorMetadata": true,
    "experimentalDecorators": true,
    "lib": [ "es2015", "dom" ],
    "noImplicitAny": true,
    "suppressImplicitAnyIndexErrors": true
  },
  "angularCompilerOptions": {
    "genDir": "./src/locale"
  }
}

在运行npm run internationalize时,它正在投掷

> m.zbor.md@1.0.0 internationalize /Volumes/Git/m.zbor.md
> ng-xi18n -p tsconfig.json

TypeError: Cannot read property 'toLowerCase' of null
    at Extractor.serialize (/Volumes/Git/m.zbor.md/node_modules/@angular/compiler-cli/src/extractor.js:47:32)
    at /Volumes/Git/m.zbor.md/node_modules/@angular/compiler-cli/src/extractor.js:33:33
    at <anonymous>
    at process._tickCallback (internal/process/next_tick.js:188:7)
    at Function.Module.runMain (module.js:667:11)
    at startup (bootstrap_node.js:187:16)
    at bootstrap_node.js:607:3
Extraction failed
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! m.zbor.md@1.0.0 internationalize: `ng-xi18n -p tsconfig.json`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the m.zbor.md@1.0.0 internationalize script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR!     /Users/danvrajmas/.npm/_logs/2018-01-24T08_39_31_131Z-debug.log
Dans-iMac:m.zbor.md danvrajmas$ 

我的tsconfig位于/ src目录中,不在root中。我试图进入root同样的错误。我无法理解是什么问题,目录上的权限是777。我尝试在线搜索但没有结果。

2 个答案:

答案 0 :(得分:0)

尝试

"internationalize": "ng xi18n -p tsconfig.json"

应该是ng x18n而不是ng-x18n

答案 1 :(得分:0)

我建议您在使用“ toLowerCase”的位置搜索应用程序。可能这不是有效功能或未正确导入。 那可能会解决您的问题。 在我的项目中,直到所有问题都没有解决(例如事件调用不存在的未在ng serve上触发的功能)后,命令才会运行