2017-04-25 84 views
0

我正在嘗試使用Angular 2中的Hello World,當我運行「npm start」時它不起作用。我定義的package.json但開始的腳本開始不工作「npm start」本地服務器不能正常工作

這是我的package.json設置

{ 
    "name": "ng2-helloworld", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"", 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "lite": "lite-server", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "typings": "typings", 
    "postinstall": "typing install" 
    }, 
    "keywords": [], 
    "author": "", 
    "license": "ISC", 
    "devDependencies": { 
    "concurrently": "^3.4.0", 
    "lite-server": "^2.3.0", 
    "typescript": "^2.2.2", 
    "typings": "^2.1.1" 
    } 
} 

這是我tsconfig.json設置

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "moduleResolution": "none", 
     "sourceMap": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "removeComments": false, 
     "noImplicitAny": false, 
     "lib": ["es2015", "dom"] 
    } 
} 

回答

0

你錯你寫沒有,而不是節點糾正代碼如下

這是我的package.json設置

{ 
    "name": "ng2-helloworld", 
    "version": "1.0.0", 
    "description": "", 
    "main": "index.js", 
    "scripts": { 
    "start": "tsc && concurrently \"npm run tsc:w\" \"npm run lite\"", 
    "test": "echo \"Error: no test specified\" && exit 1", 
    "lite": "lite-server", 
    "tsc": "tsc", 
    "tsc:w": "tsc -w", 
    "typings": "typings", 
    "postinstall": "typing install" 
    }, 
    "keywords": [], 
    "author": "", 
    "license": "ISC", 
    "devDependencies": { 
    "concurrently": "^3.4.0", 
    "lite-server": "^2.3.0", 
    "typescript": "^2.2.2", 
    "typings": "^2.1.1" 
    } 
} 

這是我tsconfig.json設置

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "sourceMap": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "removeComments": false, 
     "noImplicitAny": false, 
     "lib": ["es2015", "dom"] 
    } 
} 
+0

謝謝@Rameez –

0

你可以試試ng serve 請參考此快速入門angular

0

我通過將「moduleResolution」替換爲「無」與「moduleResol」 ution「:‘節點’, 在

糾正代碼是在這裏

{ 
    "compilerOptions": { 
     "target": "es5", 
     "module": "commonjs", 
     "moduleResolution": "node", 
     "sourceMap": true, 
     "emitDecoratorMetadata": true, 
     "experimentalDecorators": true, 
     "removeComments": false, 
     "noImplicitAny": false, 
     "lib": ["es2015", "dom"] 
    } 
} 
相關問題