Angular 调试

我们新建一个项目。执行 ng server 会启动一个网站。

1. 执行 where ng 。看看ng 是什么.

D:\Abp学习\angular\Mytest>where ng
C:\Users\QiGongbo\AppData\Roaming\npm\ng
C:\Users\QiGongbo\AppData\Roaming\npm\ng.cmd

实际执行到了ng.cmd:

@IF EXIST "%~dp0\node.exe" (    # C:\Users\QiGongbo\AppData\Roaming\npm\\node_modules\@angular\cli\bin\ng
  "%~dp0\node.exe"  "%~dp0\node_modules\@angular\cli\bin\ng" %*
) ELSE (
  @SETLOCAL
  @SET PATHEXT=%PATHEXT:;.JS;=;%
  node  "%~dp0\node_modules\@angular\cli\bin\ng" %*
)

这个 ng 是个JS文件。 文件是这样的:

#!/usr/bin/env node
‘use strict‘;

// Provide a title to the process in `ps`.
// Due to an obscure Mac bug, do not start this title with any symbol.
console.log(process);
try {
  process.title = ‘ng ‘ + Array.from(process.argv).slice(2).join(‘ ‘);
} catch(_) {
  // If an error happened above, use the most basic title.
  process.title = ‘ng‘;
}

// Some older versions of Node do not support let or const.
var version = process.version.substr(1).split(‘.‘);
if (Number(version[0]) < 8 || (Number(version[0]) === 8 && Number(version[1]) < 9)) {
  process.stderr.write(
    ‘You are running version ‘ + process.version + ‘ of Node.js, which is not supported by Angular CLI v6.\n‘ +
    ‘The official Node.js version that is supported is 8.9 and greater.\n\n‘ +
    ‘Please visit https://nodejs.org/en/ to find instructions on how to update Node.js.\n‘
  );

  process.exit(3);
}

require(‘../lib/init‘);

最后引用了  require(‘../lib/init‘);

init.js 如下:

"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
/**
 * @license
 * Copyright Google Inc. All Rights Reserved.
 *
 * Use of this source code is governed by an MIT-style license that can be
 * found in the LICENSE file at https://angular.io/license
 */
require("symbol-observable");
// symbol polyfill must go first
// tslint:disable-next-line:ordered-imports import-groups
const core_1 = require("@angular-devkit/core");
const node_1 = require("@angular-devkit/core/node");
const fs = require("fs");
const path = require("path");
const semver_1 = require("semver");
const stream_1 = require("stream");
const config_1 = require("../utilities/config");
const packageJson = require(‘../package.json‘);
function _fromPackageJson(cwd) {
    cwd = cwd || process.cwd();
    do {
        const packageJsonPath = path.join(cwd, ‘node_modules/@angular/cli/package.json‘);
        if (fs.existsSync(packageJsonPath)) {
            const content = fs.readFileSync(packageJsonPath, ‘utf-8‘);
            if (content) {
                const json = JSON.parse(content);
                if (json[‘version‘]) {
                    return new semver_1.SemVer(json[‘version‘]);
                }
            }
        }
        // Check the parent.
        cwd = path.dirname(cwd);
    } while (cwd != path.dirname(cwd));
    return null;
}
// Check if we need to profile this CLI run.
if (process.env[‘NG_CLI_PROFILING‘]) {
    let profiler;
    try {
        profiler = require(‘v8-profiler-node8‘); // tslint:disable-line:no-implicit-dependencies
    }
    catch (err) {
        throw new Error(`Could not require ‘v8-profiler-node8‘. You must install it separetely with` +
            `‘npm install v8-profiler-node8 --no-save.\n\nOriginal error:\n\n${err}`);
    }
    profiler.startProfiling();
    const exitHandler = (options) => {
        if (options.cleanup) {
            const cpuProfile = profiler.stopProfiling();
            fs.writeFileSync(path.resolve(process.cwd(), process.env.NG_CLI_PROFILING || ‘‘) + ‘.cpuprofile‘, JSON.stringify(cpuProfile));
        }
        if (options.exit) {
            process.exit();
        }
    };
    process.on(‘exit‘, () => exitHandler({ cleanup: true }));
    process.on(‘SIGINT‘, () => exitHandler({ exit: true }));
    process.on(‘uncaughtException‘, () => exitHandler({ exit: true }));
}
let cli;
try {
    const projectLocalCli = node_1.resolve(‘@angular/cli‘, {
        checkGlobal: false,
        basedir: process.cwd(),
        preserveSymlinks: true,
    });
    // This was run from a global, check local version.
    const globalVersion = new semver_1.SemVer(packageJson[‘version‘]);
    let localVersion;
    let shouldWarn = false;
    try {
        localVersion = _fromPackageJson();
        shouldWarn = localVersion != null && globalVersion.compare(localVersion) > 0;
    }
    catch (e) {
        // eslint-disable-next-line no-console
        console.error(e);
        shouldWarn = true;
    }
    if (shouldWarn && config_1.isWarningEnabled(‘versionMismatch‘)) {
        const warning = core_1.terminal.yellow(core_1.tags.stripIndents `
    Your global Angular CLI version (${globalVersion}) is greater than your local
    version (${localVersion}). The local Angular CLI version is used.

    To disable this warning use "ng config -g cli.warnings.versionMismatch false".
    `);
        // Don‘t show warning colorised on `ng completion`
        if (process.argv[2] !== ‘completion‘) {
            // eslint-disable-next-line no-console
            console.error(warning);
        }
        else {
            // eslint-disable-next-line no-console
            console.error(warning);
            process.exit(1);
        }
    }
    // No error implies a projectLocalCli, which will load whatever
    // version of ng-cli you have installed in a local package.json
    cli = require(projectLocalCli);
}
catch (_a) {
    // If there is an error, resolve could not find the ng-cli
    // library from a package.json. Instead, include it from a relative
    // path to this script file (which is likely a globally installed
    // npm package). Most common cause for hitting this is `ng new`
    cli = require(‘./cli‘);
}
if (‘default‘ in cli) {
    cli = cli[‘default‘];
}
// This is required to support 1.x local versions with a 6+ global
let standardInput;
try {
    standardInput = process.stdin;
}
catch (e) {
    delete process.stdin;
    process.stdin = new stream_1.Duplex();
    standardInput = process.stdin;
}
cli({
    cliArgs: process.argv.slice(2),
    inputStream: standardInput,
    outputStream: process.stdout,
})
    .then((exitCode) => {
    process.exit(exitCode);
})
    .catch((err) => {
    console.error(‘Unknown error: ‘ + err.toString());
    process.exit(127);
});
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5pdC5qcyIsInNvdXJjZVJvb3QiOiIuLyIsInNvdXJjZXMiOlsicGFja2FnZXMvYW5ndWxhci9jbGkvbGliL2luaXQudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6Ijs7QUFBQTs7Ozs7O0dBTUc7QUFDSCw2QkFBMkI7QUFDM0IsZ0NBQWdDO0FBQ2hDLHlEQUF5RDtBQUN6RCwrQ0FBc0Q7QUFDdEQsb0RBQW9EO0FBQ3BELHlCQUF5QjtBQUN6Qiw2QkFBNkI7QUFDN0IsbUNBQWdDO0FBQ2hDLG1DQUFnQztBQUNoQyxnREFBdUQ7QUFFdkQsTUFBTSxXQUFXLEdBQUcs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RTdHJlYW06IHByb2Nlc3Muc3Rkb3V0LFxufSlcbiAgLnRoZW4oKGV4aXRDb2RlOiBudW1iZXIpID0+IHtcbiAgICBwcm9jZXNzLmV4aXQoZXhpdENvZGUpO1xuICB9KVxuICAuY2F0Y2goKGVycjogRXJyb3IpID0+IHtcbiAgICBjb25zb2xlLmVycm9yKCdVbmtub3duIGVycm9yOiAnICsgZXJyLnRvU3RyaW5nKCkpO1xuICAgIHByb2Nlc3MuZXhpdCgxMjcpO1xuICB9KTtcbiJdfQ==

原文地址:https://www.cnblogs.com/qgbo/p/11635697.html

时间: 2024-11-09 04:58:29

Angular 调试的相关文章

angular 调试 js (分 karms protractor / test e2e unit )

首页订阅 Protractor端到端的AngularJS测试框架教程 2014年01月18日 分类:教程, JavaScript, AngularJS Protractor是一个建立在WebDriverJS基础上的端到端(E2E)的AngularJS JavaScript Web应用程序测试框架.Protractor全自动化真实的模拟用户在真正的浏览器中操作.运行并测试开发者的应用程序. 安装Protractor和WebDriver 通过npm进行全局安装protractor Node.js模块

ngModel 值不更新/显示

angular中的$scope是页面(view)和数据(model)之间的桥梁,它链接了页面元素和model,也是angular双向绑定机制的核心. 而ngModel是angular用来处理表单(form)的最重要的指令,它链接了页面表单中的可交互元素和位于$scope之上的model,它会自动把ngModel所指向的model值渲染到form表单的可交互元素上,同时也会根据用户在form表单的输入或交互来更新此model值. 在源码中,model值的格式化.解析.验证都是由ngModel指令所

用AngularJS开发下一代应用(学习笔记)

核心特性:MVC, 模块化, 自动化双向绑定数据,语义化标签,依赖注入 MVC 1970年smalltalk MVC核心理念:你应该把你管理数据的代码(model).应用逻辑代码(controller).向用户展示的代码(view)清晰的分离开 数据绑定:声明UI中某个部分需要映射到某个JS属性,然后让他们自己去同步 依赖注入:(自动解析依赖关系)只是简单的获取他们所需要的东西,而不需要创建那些它们所以来的东西,遵循了(Law of Demeter)也叫最少知识原则,意味着,我们不应该去操心任何

Visual Studio Code 通过 Chrome插件Type Script断点调试Angular 2

1. 下载Visual Studio Code (https://code.visualstudio.com/) 2. 安装插件Debugger for chrome 3. 确定tsconfig.json配置 "sourceMap": true { "compileOnSave": false, "compilerOptions": { "outDir": "./dist/out-tsc", "s

.Net Core + Angular Cli 开发环境搭建

一.基础环境配置 1.安装VS 2017 v15.3或以上版本 2.安装VS Code最新版本 3.安装Node.js v6.9以上版本 4.重置全局npm源,修正为 淘宝的 NPM 镜像: npm install -g cnpm --registry=https://registry.npm.taobao.org 5.安装TypeScript cnpm install -g typescript typings 6.安装 AngularJS CLI cnpm install -g @angul

Angular 2.0--1

Angular 2.0 从0到1 (五) 第一节:Angular 2.0 从0到1 (一)第二节:Angular 2.0 从0到1 (二)第三节:Angular 2.0 从0到1 (三)第四节:Angular 2.0 从0到1 (四)第五节:Angular 2.0 从0到1 (五)第六节:Angular 2.0 从0到1 (六)第七节:Angular 2.0 从0到1 (七)第八节:Angular 2.0 从0到1 (八)番外:Angular 2.0 从0到1 Rx-隐藏在Angular 2.x

2.angular MVC

AngularJs的MVC全部借助于$scope(作用域)实现 1.ng指令 <!doctype html> <html ng-app> <head> <meta charset="utf-8"> </head> <body> <div ng-controller="CommonController"> <div ng-controller="Controller1&

angular代码设计之异常日志设计

angular代码分析之异常日志设计 错误异常是面向对象开发中的记录提示程序执行问题的一种重要机制,在程序执行发生问题的条件下,异常会在中断程序执行,同时会沿着代码的执行路径一步一步的向上抛出异常,最终会由顶层抛出异常信息.而与异常同时出现的往往是日志,而日志往往需要记录具体发生异常的模块.编码.详细的错误信息.执行堆栈等,方便问题的快速定位分析.angularjs作为前端的框架,其对异常信息的处理是怎样的呢? 一.定义模块和异常类型 首先每个模块的日志模块编码是一样的,只需要本模块负责初始化一

码农视角 - Angular 框架起步

开发环境 1.npm 安装最新的Nodejs,便包含此工具.类似Nuget一样的东西,不过与Nuget不同的是,这玩意完全是命令行的.然后用npm来安装开发环境,也就是下边的angular cli. 2.Angular Cli 通过命令行创建项目,“编译”代码,启动调度环境等功能.angular本身使用typescript编写,需要通过ng命令,将相关的ts代码转换成js代码,以便在浏览器中运行. 安装angular cli npm install -g @angular/cli 3.IDE 复