Angular2快速入门NPM开始无法正常工作

Angular2快速入门NPM开始无法正常工作

本文介绍了Angular2快速入门NPM开始无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我知道Angular2测试版刚刚发布,但我无法重现从他们的官方网站教程(步骤的)。也许有人有过类似的问题,并知道在为了解决这个该怎么办?当我尝试启动 NPM启动命令应用我得到的输出是这样的:

  0的信息,它的工作,如果它与行结束
1冗余CLI ['节点','在/ usr / local / bin目录/故宫','开始']
2使用信息[email protected]
3信息使用[email protected]
4冗长运行脚本['$ P​​ $ PSTART','开始','poststart']
5信息preSTART [email protected]
6资讯开始[email protected]
7冗长不安全烫发生命周期中的真实
8资讯[email protected]~~V~~aux未能给exec启动脚本
9详细的堆栈错误:[email protected]启动:`并发故宫运行TSC:W,故宫运行精简版`
9详细的堆栈退出状态127
匿名> 9日EventEmitter&LT详细的堆栈; (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9日EventEmitter.emit详细的堆栈(events.js:110:17)
匿名> 9在子进程&LT详细的堆栈; (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:14:12)
9日ChildProcess.emit详细的堆栈(events.js:110:17)
9日maybeClose详细的堆栈(child_process.js:1015:16)
9日Process.ChildProcess._handle.onexit详细的堆栈(child_process.js:1087:5)
10详细pkgid [email protected]
11详细CWD /用户/ tmrovsky /文件/ angular2 / angular2,快速入门
12错误达尔文13.4.0
13错误argv的节点,在/ usr / local / bin目录/故宫开始
14错误节点v0.12.2
15错误NPM v2.7.4
16错误code ELIFECYCLE
17错误[email protected]~~MD~~aux开始:`并发故宫运行TSC:W,故宫运行精简版`
17错误号127
18错误在[email protected]启动脚本失败并发故宫运行TSC:W,故宫运行精简版'。
18错误这是最有可能与angular2,快速启动包有问题,
18错误不是NPM本身。
18错误告诉笔者,这种失败在系统上:
18错误并发故宫运行TSC:W,故宫运行精简版
18错误您可以通过获得他们的信息:
18错误NPM所有者LS angular2,快速入门
18错误有可能是额外的日志输出上面。
19冗长退出[1,真]

我有:
打字稿1.7.5版本
节点0.12.2提供版本

也许有人可以帮助解决这个问题:)?

的package.json:

  {
  名:angular2-快速入门
  版本:1.0.0
  脚本:{
    TSC:台糖
    TSC:W:TSC -w
    精简版:精简版服务器
    开始:并发\\故宫运行TSC:W \\\\运行故宫精简版\\
  },
  许可证:ISC
  依赖:{
    angular2:2.0.0-beta.0
    systemjs:0.19.6,
    ES6-承诺:^ 3.0.2
    ES6-垫片:^ 0.33.3
    反映了元数据:0.1.2
    rxjs:5.0.0-beta.0
    zone.js:0.5.10
  },
  devDependencies:{
    同时:^ 1.0.0
    精简版服务器:^ 1.3.1
    打字稿:^ 1.7.3
  }
}

index.html的:

 < HTML和GT;< HEAD>
    <标题> 2角及快速入门LT; /标题>    <! - 1.装入库 - >
    <脚本SRC =node_modules / ES6-垫片/ ES6-shim.js>< / SCRIPT>
    <脚本SRC =node_modules / angular2 /包/ angular2-polyfills.js>< / SCRIPT>
    <脚本SRC =node_modules / systemjs /距离/ system.src.js>< / SCRIPT>
    <脚本SRC =node_modules / rxjs /包/ Rx.js>< / SCRIPT>
    <脚本SRC =node_modules / angular2 /包/ angular2.dev.js>< / SCRIPT>    <! - 2.配置SystemJS - >
    <脚本>
        System.config({
            包:{
                应用:{
                    格式为:注册,
                    defaultExtension:'JS'
                }
            }
        });
        System.import(应用程序/启动)
                。然后(NULL,console.error.bind(控制台));
    < / SCRIPT>< /头><! - 3显示应用程序 - >
<身体GT;
<我的应用>加载...< /我的应用>
< /身体GT;< / HTML>

app.components.ts:

 进口{}组件从angular2 /核心;@零件({
    选择:我的应用,
    模板:'< H1>我的第一角2应用< / H1>,
})出口类AppComponent {}

boot.js:

 从'angular2 /平台/浏览器的进口{}引导
进口{} AppComponent从'./app.component引导(AppComponent);


解决方案

为了让 NPM启动我跑,我必须确保我已经在全球安装了一些的devDependencies。您是否尝试过:


  • NPM安装-g同时

  • NPM安装精简版-g服务器

  • NPM安装-g打字稿

My Directory Tree

I know Angular2 beta has just been released but I can't reproduce the steps from their official site tutorial ( https://angular.io/docs/ts/latest/quickstart.html ). Maybe someone has had similar issues and knows what to do in order to fix the this? When I try to start the application with npm start command I get output like this:

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'start' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info prestart [email protected]
6 info start [email protected]
7 verbose unsafe-perm in lifecycle true
8 info [email protected] Failed to exec start script
9 verbose stack Error: [email protected] start: `concurrent "npm run tsc:w" "npm run lite" `
9 verbose stack Exit status 127
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack     at EventEmitter.emit (events.js:110:17)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:14:12)
9 verbose stack     at ChildProcess.emit (events.js:110:17)
9 verbose stack     at maybeClose (child_process.js:1015:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid [email protected]
11 verbose cwd /Users/tmrovsky/Documents/angular2/angular2-quickstart
12 error Darwin 13.4.0
13 error argv "node" "/usr/local/bin/npm" "start"
14 error node v0.12.2
15 error npm  v2.7.4
16 error code ELIFECYCLE
17 error [email protected] start: `concurrent "npm run tsc:w" "npm run lite" `
17 error Exit status 127
18 error Failed at the [email protected] start script 'concurrent "npm run tsc:w" "npm run lite" '.
18 error This is most likely a problem with the angular2-quickstart package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     concurrent "npm run tsc:w" "npm run lite"
18 error You can get their info via:
18 error     npm owner ls angular2-quickstart
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]

I had:typescript 1.7.5 versionnode 0.12.2 version

Maybe someone could help solve the problem :) ?

package.json:

{
  "name": "angular2-quickstart",
  "version": "1.0.0",
  "scripts": {
    "tsc": "tsc",
    "tsc:w": "tsc -w",
    "lite": "lite-server",
    "start": "concurrent \"npm run tsc:w\" \"npm run lite\" "
  },
  "license": "ISC",
  "dependencies": {
    "angular2": "2.0.0-beta.0",
    "systemjs": "0.19.6",
    "es6-promise": "^3.0.2",
    "es6-shim": "^0.33.3",
    "reflect-metadata": "0.1.2",
    "rxjs": "5.0.0-beta.0",
    "zone.js": "0.5.10"
  },
  "devDependencies": {
    "concurrently": "^1.0.0",
    "lite-server": "^1.3.1",
    "typescript": "^1.7.3"
  }
}

index.html:

<html>

<head>
    <title>Angular 2 QuickStart</title>

    <!-- 1. Load libraries -->
    <script src="node_modules/es6-shim/es6-shim.js"></script>
    <script src="node_modules/angular2/bundles/angular2-polyfills.js"></script>
    <script src="node_modules/systemjs/dist/system.src.js"></script>
    <script src="node_modules/rxjs/bundles/Rx.js"></script>
    <script src="node_modules/angular2/bundles/angular2.dev.js"></script>

    <!-- 2. Configure SystemJS -->
    <script>
        System.config({
            packages: {
                app: {
                    format: 'register',
                    defaultExtension: 'js'
                }
            }
        });
        System.import('app/boot')
                .then(null, console.error.bind(console));
    </script>

</head>

<!-- 3. Display the application -->
<body>
<my-app>Loading...</my-app>
</body>

</html>

app.components.ts:

import {Component} from 'angular2/core';

@Component({
    selector: 'my-app',
    template: '<h1>My First Angular 2 App</h1>',
})

export class AppComponent {}

boot.js:

import {bootstrap} from 'angular2/platform/browser'
import  {AppComponent} from './app.component'

bootstrap(AppComponent);
解决方案

In order to get npm start running for me, I had to make sure I had globally installed some of the devDependencies. Have you tried:

  • npm install -g concurrently
  • npm install -g lite-server
  • npm install -g typescript

这篇关于Angular2快速入门NPM开始无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

08-06 14:44