2017-02-28 90 views
3

ng -v:1.0.0-beta.32.3不能運行在我的角度,CLI項目納克皮棉

"devDependencies": { 
    "@angular/compiler-cli": "2.4.4", 
    "@types/jasmine": "^2.5.38", 
    "@types/node": "^6.0.42", 
    "codelyzer": "~2.0.0-beta.4", 
    "jasmine-core": "^2.5.2", 
    "jasmine-spec-reporter": "^3.2.0", 
    "karma": "^1.4.1", 
    "karma-cli": "^1.0.1", 
    "karma-jasmine": "^1.1.0", 
    "karma-phantomjs-launcher": "^1.0.2", 
    "karma-remap-istanbul": "^0.6.0", 
    "protractor": "^4.0.13", 
    "ts-node": "~2.0.0", 
    "tslint": "^4.4.2", 
    "typescript": "~2.0.3" 
    } 

/tslint.json

{ 
    "rulesDirectory": [ 
    "node_modules/codelyzer" 
    ], 
    "rules": { 
    "class-name": true, 
    "comment-format": [ 
     true, 
     "check-space" 
    ], 
    "curly": true, 
    "eofline": true, 
    "forin": true, 
    "indent": [ 
     true, 
     "spaces" 
    ], 
    "label-position": true, 
    "max-line-length": [ 
     false, 
     140 
    ], 
    "member-access": false, 
    "member-ordering": [ 
     true, 
     "static-before-instance" 
    ], 
    "no-arg": true, 
    "no-bitwise": true, 
    "no-console": [ 
     true, 
     "debug", 
     "info", 
     "time", 
     "timeEnd", 
     "trace" 
    ], 
    "no-construct": true, 
    "no-debugger": true, 
    "no-duplicate-variable": true, 
    "no-empty": false, 
    "no-eval": true, 
    "no-inferrable-types": true, 
    "no-shadowed-variable": true, 
    "no-string-literal": false, 
    "no-switch-case-fall-through": true, 
    "no-trailing-whitespace": true, 
    "no-unused-expression": true, 
    "no-use-before-declare": true, 
    "no-var-keyword": true, 
    "object-literal-sort-keys": false, 
    "one-line": [ 
     true, 
     "check-open-brace", 
     "check-catch", 
     "check-else", 
     "check-whitespace" 
    ], 
    "quotemark": [ 
     true, 
     "single" 
    ], 
    "radix": true, 
    "semicolon": [ 
     "always" 
    ], 
    "triple-equals": [ 
     true, 
     "allow-null-check" 
    ], 
    "typedef-whitespace": [ 
     true, 
     { 
     "call-signature": "nospace", 
     "index-signature": "nospace", 
     "parameter": "nospace", 
     "property-declaration": "nospace", 
     "variable-declaration": "nospace" 
     } 
    ], 
    "variable-name": false, 
    "whitespace": [ 
     true, 
     "check-branch", 
     "check-decl", 
     "check-operator", 
     "check-separator", 
     "check-type" 
    ], 

    "use-input-property-decorator": true, 
    "use-output-property-decorator": true, 
    "use-host-property-decorator": true, 
    "no-input-rename": true, 
    "no-output-rename": true, 
    "use-life-cycle-interface": true, 
    "use-pipe-transform-interface": true, 
    "component-class-suffix": true, 
    "directive-class-suffix": true 
    } 
} 

/src目錄/ tsconfig。 JSON

{ 
    "compilerOptions": { 
    "baseUrl": "", 
    "declaration": false, 
    "emitDecoratorMetadata": true, 
    "experimentalDecorators": true, 
    "lib": ["es6", "dom", "es2017.object"], 
    "mapRoot": "./", 
    "module": "es6", 
    "moduleResolution": "node", 
    "noUnusedParameters": false, 
    "noUnusedLocals": true, 
    "outDir": "../dist/out-tsc", 
    "sourceMap": true, 
    "target": "es5", 
    "typeRoots": [ 
     "../node_modules/@types" 
    ], 
    "paths": { 
     "angular2/*": [ 
     "@angular/*" 
     ] 
    } 
    } 
} 

.angular-cli.json

{ 
    "project": { 
    "version": "1.0.0-beta.32.3", 
    "name": "myapp" 
    }, 
    "apps": [ 
    { 
     "root": "src", 
     "outDir": "dist", 
     "assets": [ 
     "assets", 
     "favicon.ico" 
     ], 
     "index": "index.html", 
     "main": "main.ts", 
     "test": "test.ts", 
     "tsconfig": "tsconfig.json", 
     "prefix": "app", 
     "mobile": false, 
     "styles": [ 
     "../node_modules/normalize-css/normalize.css", 
     "styles.styl" 
     ], 
     "scripts": [], 
     "environmentSource": "environments/environment.ts", 
     "environments": { 
     "dev": "environments/environment.ts", 
     "prod": "environments/environment.prod.ts" 
     } 
    } 
    ], 
    "addons": [], 
    "packages": [], 
    "e2e": { 
    "protractor": { 
     "config": "./protractor.conf.js" 
    } 
    }, 
    "test": { 
    "karma": { 
     "config": "./karma.conf.js" 
    } 
    }, 
    "defaults": { 
    "styleExt": "styl", 
    "prefixInterfaces": false, 
    "inline": { 
     "style": false, 
     "template": false 
    }, 
    "spec": { 
     "class": false, 
     "component": true, 
     "directive": true, 
     "module": false, 
     "pipe": true, 
     "service": true 
    } 
    } 
} 

當我運行ng lint,我得到的黃色粉筆錯誤No lint config(s) found. If this is not intended, run "ng update".(爲NG update命令已爲beta.32.3的被移除這聽起來真的很奇怪)

什麼可能出現配置錯誤?

+0

你可以添加你的'.angular-cli.json'文件?你最近是否升級到另一個cli版本?你爲什麼不在你的'package.json'的devDependencies中擁有@ angular/cli? – Dinistro

+0

https://github.com/angular/angular-cli/issues/4360 –

+1

@Dinistro這是在主要的deps,我現在把它移到devDeps。是的,這個項目有一個「紗線升級」,可能會造成一些混亂。 – user776686

回答

8

你忘了把這裏提到的一些重大變化:https://github.com/angular/angular-cli/blob/master/CHANGELOG.md

要解決掉毛問題,添加下面進入.angular-cli.json文件。

"lint": [ 
    { 
    "files": "src/**/*.ts", 
    "project": "src/tsconfig.json" 
    }, 
    { 
    "files": "e2e/**/*.ts", 
    "project": "e2e/tsconfig.json" 
    } 
], 

它也可以是,你的全球和本地版本的cli是不同的。請運行下面的命令來確保,兩個具有相同的版本(我會直接升級到rc.0):

npm i -g @angular/[email protected] 

rm -rf node_modules/ 

npm i -D @angular/[email protected] 
npm i 

在這之後,你應該在全球有最新版本,並在當地

+1

我之前有過這種情況,但後來我收到一條消息,說我的本地版本被使用,這是一個非常好的策略。所以,除非他們改變這個策略,否則我不認爲這會是一個問題。感謝您提出它。 – user776686