"npm start" 本地服务器不工作
"npm start" local server is not working
我正在 Angular 2 中尝试 Hello World,但 运行 "npm start" 它不起作用。我在 package.json 的脚本中定义了启动,但启动不起作用
这是我的 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"]
}
}
你可以试试ng serve
将此作为快速入门参考 angular
我已通过将 "moduleResolution": "none" 替换为 "moduleResolution": "node" 而得到更正
在
更正后的代码在这里
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"lib": ["es2015", "dom"]
}
}
你写错了 none 而不是节点更正代码如下
这是我的 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"]
}
}
我正在 Angular 2 中尝试 Hello World,但 运行 "npm start" 它不起作用。我在 package.json 的脚本中定义了启动,但启动不起作用
这是我的 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"]
}
}
你可以试试ng serve
将此作为快速入门参考 angular
我已通过将 "moduleResolution": "none" 替换为 "moduleResolution": "node" 而得到更正 在
更正后的代码在这里
{
"compilerOptions": {
"target": "es5",
"module": "commonjs",
"moduleResolution": "node",
"sourceMap": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"removeComments": false,
"noImplicitAny": false,
"lib": ["es2015", "dom"]
}
}
你写错了 none 而不是节点更正代码如下
这是我的 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"]
}
}