0

当我运行“npm start”时,我正在 Angular 2 中尝试 Hello World,但它不起作用。我在 package.json 的脚本中定义了 start 但 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"]
    }
}
4

3 回答 3

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"]
    }
}
于 2017-05-09T05:46:15.387 回答
0

我通过将“moduleResolution”:“none”替换为“moduleResolution”:“node”,在

更正的代码在这里

{
    "compilerOptions": {
        "target": "es5",
        "module": "commonjs",
        "moduleResolution": "node",
        "sourceMap": true,
        "emitDecoratorMetadata": true,
        "experimentalDecorators": true,
        "removeComments": false,
        "noImplicitAny": false,
        "lib": ["es2015", "dom"]
    }
}
于 2017-04-25T09:36:12.320 回答
0

你可以尝试ng serve 参考这个快速入门角度

于 2017-04-25T09:29:44.060 回答