2017-04-25 74 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"] 
    } 
}