我正在开发Windows中的Angular 2应用程序。这一刻一切正常,直到我尝试在CentOS上运行app。当我在Linux上编译打字稿时给我带来了错误,我很困惑。两个系统都具有相同的节点和npm版本:
我发现,在" npm install"之后,Linux上出现了一些错误。我必须运行" npm run postinstall"手动。其余的错误很容易通过代码更改来清理。
为什么" npm运行tsc"不会在Windows上抛出错误?
" npm run tsc" CentOS上的输出
> my-app@1.0.0 tsc /root/MyApp/app
> tsc
app/main-panel/main-info.component.ts(22,12): error TS7006: Parameter 'data' implicitly has an 'any' type.
app/main-panel/minor-info.component.ts(23,12): error TS7006: Parameter 'data' implicitly has an 'any' type.
app/main-panel/data.component.ts(23,12): error TS7006: Parameter 'data' implicitly has an 'any' type.
app/data.service.ts(1,25): error TS2307: Cannot find module 'rxjs/rx'.
npm ERR! Linux 3.10.0-327.28.3.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "run" "tsc"
npm ERR! node v4.5.0
npm ERR! npm v3.10.7
npm ERR! code ELIFECYCLE
npm ERR! my-app@1.0.0 tsc: `tsc`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the my-app@1.0.0 tsc script 'tsc'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the my-app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR! tsc
npm ERR! You can get information on how to open an issue for this project with:
npm ERR! npm bugs my-app
npm ERR! Or if that isn't available, you can get their info via:
npm ERR! npm owner ls my-app
npm ERR! There is likely additional logging output above.
npm ERR! Please include the following file with any support request:
npm ERR! /root/MyApp/app/npm-debug.log
tsconfig.json
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": true,
"suppressImplicitAnyIndexErrors": true
},
"exclude": [
"node_modules",
"typings/main",
"typings/main.d.ts"
]
}
的package.json
{
"name": "my-app",
"version": "1.0.0",
"description": "My App",
"scripts": {
"start": "tsc && concurrently \"watch-less -d ./less -r ./css -e .css\" \"tsc -w\" \"lite-server\" ",
"watch": "concurrently \"watch-less -d ./less -r ./css -e .css\" \"tsc -w\"",
"lite": "lite-server",
"postinstall": "typings install",
"tsc": "tsc",
"tsc:w": "tsc -w",
"typings": "typings",
"e2e": "tsc && concurrently \"http-server -s\" \"protractor protractor.config.js\" --kill-others --success first"
},
"license": "ISC",
"dependencies": {
"@angular/common": "2.0.0-rc.6",
"@angular/compiler": "2.0.0-rc.6",
"@angular/compiler-cli": "0.6.0",
"@angular/core": "2.0.0-rc.6",
"@angular/forms": "2.0.0-rc.6",
"@angular/http": "2.0.0-rc.6",
"@angular/platform-browser": "2.0.0-rc.6",
"@angular/platform-browser-dynamic": "2.0.0-rc.6",
"@angular/router": "3.0.0-rc.2",
"@angular/upgrade": "2.0.0-rc.6",
"core-js": "^2.4.1",
"reflect-metadata": "^0.1.3",
"rxjs": "5.0.0-beta.11",
"systemjs": "0.19.27",
"zone.js": "^0.6.17",
"angular2-in-memory-web-api": "0.0.18"
},
"devDependencies": {
"canonical-path": "0.0.2",
"concurrently": "^2.2.0",
"jasmine": "^2.4.1",
"karma": "^1.1.0",
"karma-chrome-launcher": "^1.0.1",
"karma-firefox-launcher": "^1.0.0",
"karma-htmlfile-reporter": "^0.3.4",
"karma-jasmine": "^1.0.2",
"karma-phantomjs-launcher": "^1.0.1",
"lite-server": "^2.2.2",
"protractor": "^4.0.0",
"protractor-jasmine2-screenshot-reporter": "^0.3.2",
"typescript": "^1.8.10",
"typings": "^1.3.2",
"watch-less": "0.0.4"
}
}