标签: angular-cli

使用chrome web开发人员工具在Angular 2 CLI项目中未显示的Typescript文件

我使用angular2 CLI(ember cli)生成了一个打字稿项目.我正在使用Chromium Web Developer工具进行调试.我在开发者工具设置中选择了"启用javascript源地图".我看到源视图中列出的.js文件和.ts.但是,当我选择它们时,.ts(typescript)文件显示为空,即它无法找到它们.

屏幕打印显示情况:

在此输入图像描述

如果我选择它们,我可以看到.js文件的文本.

.ts文件没有被复制到dist目录中,这对我来说似乎是一个问题,但我看到其他地方的例子显示了典型的angular2 cli dist结构,它们也没有.ts文件.

我的"tsconfig.json"的相关部分显示我启用了源映射:

 1   "compileOnSave": false,                                                                            
  2   "compilerOptions": {                                                                               
  3     "declaration": false,                                                                            
  4     "emitDecoratorMetadata": true,                                                                   
  5     "experimentalDecorators": true,                                                                  
  6     "mapRoot": "",                                                                                   
  7     "module": "system",                                                                              
  8     "moduleResolution": "node",                                                                      
  9     "noEmitOnError": true,                                                                           
 10     "noImplicitAny": false,                                                                          
 11     "outDir": "../dist/",                                                                            
 12     "rootDir": ".",                                                                                  
 13     "sourceMap": true,                                                                               
 14     "sourceRoot": "/",                                                                               
 15     "target": "es5"                                                                                  
 16   },                          
Run Code Online (Sandbox Code Playgroud)

js.map文件的制作和驻留在DIST目录旁边的.js文件.

映射文件示例(部分):

{"version":3,"file":"app.js","sourceRoot":"/","sources":["app.ts"],"names":[],"mappings":";;;;;;;;;;;;;YAGA,mB
Run Code Online (Sandbox Code Playgroud)

我试过:
1)将.ts文件从src复制到dist.
2)手动编辑app.js.map文件的各种尝试,例如sourceRoot和sources.

目前还不十分清楚js.map文件中的"/"是什么:项目的src目录还是dist目录?如果我编辑.js.map文件,我是否必须刷新浏览器以获取它?

我认为基本问题是它在src目录中寻找ts文件,这超出了浏览器的范围(因为它位于"../src"). …

typescript angular-cli angular

10
推荐指数
1
解决办法
7304
查看次数

错误:在angular-cli中找不到模块'lodash'?

OS

Mac OSX El Capitan

版本

angular-cli: 1.0.0-beta.8, node: 6.2.0,os: darwin x64

描述

我试图lodash在angular-cli项目中添加库:

  • npm install --save lodash
  • typings install lodash --global --save

已成功安装node_modules.

system-config.ts:

/** Map relative paths to URLs. */
const map: any = {
  'lodash': 'vendor/lodash',
};

/** User packages configuration. */
const packages: any = {
  'lodash': {
    format: 'cjs',
    defaultExtension: 'js',
    main: 'core.js'
  }
};
Run Code Online (Sandbox Code Playgroud)

角-CLI-build.js

var Angular2App = require('angular-cli/lib/broccoli/angular2-app');

module.exports = function(defaults) {
  return new Angular2App(defaults, …
Run Code Online (Sandbox Code Playgroud)

angular-cli angular

10
推荐指数
1
解决办法
2958
查看次数

如何配置`ng serve`来捕获dockersized Angular 2应用程序中的更改?

我是'dockersizing'(我希望这是正确的术语)现有的Angular 2应用程序,运行于angular-cli(1.0.0-beta.31).

ng serve每当我更新工作目录中的文件时,我都在努力找到一种方法来捕获 - 因此 - 刷新我的应用程序(像往常一样).否则,我docker-compose up --build每次都需要更改文件...

编辑:我正在探索的想法是添加一个卷.

这是我的Dockerfile:

# Dockerizing Angular 2 Client App
# @link: https://scotch.io/tutorials/create-a-mean-app-with-angular-2-and-docker-compose

# Create image based on the official Node 7 image from dockerhub
FROM node:7

# Create a directory where our app will be placed
RUN mkdir -p /usr/src/app

# Change directory so that our commands run inside this new directory
WORKDIR /usr/src/app

# Copy dependency definitions
COPY package.json /usr/src/app

# Install …
Run Code Online (Sandbox Code Playgroud)

docker docker-compose angular-cli angular

10
推荐指数
1
解决办法
3241
查看次数

如何使用Angular CLI包含自定义样式

我想将自己的自定义CSS添加到我的新Angular CLI应用程序中......

然而,我正在努力让这个工作,并没有太多关于它是如何工作的文档,这使得它有点猜测工作!

在下图中,我将自定义样式表添加到.angular-cli.json文件中,如下所示:

  "styles": [
    "styles.css",
    "app/assets/css/styles.css"
  ],
Run Code Online (Sandbox Code Playgroud)

然而,这不起作用......

好心提醒!

在此输入图像描述

angular-cli angular

10
推荐指数
1
解决办法
1万
查看次数

如何在没有互联网的情况下安装angular-cli

如果您只有zip文件来安装angular-cli - 如何在没有互联网连接的情况下安装?

angular-cli angular

10
推荐指数
2
解决办法
2万
查看次数

在2017年视觉工作室中打开angular 2 cli应用程序

我使用Angular 2 CLI创建了Angular 2应用程序.我想在Visual Studio 2017中打开该应用程序并从Visual Studio运行它.为此,我在Visual Studio中遵循了以下步骤.

  1. 在Visual Studio New Porject - > Node.js - > From Existing Node.js Code
  2. 我点击"rom Existing Node.js Code"后按照步骤操作

按照上述步骤后,它要求我插入启动脚本.我在哪里可以找到angular 2 CLI应用程序中的启动脚本?默认情况下,它server.js位于visual studio中的node.js应用程序中.

angular-cli visual-studio-2017 angular

10
推荐指数
1
解决办法
1万
查看次数

Angular4 core.es5.js使用类装饰器时需要使用未反射的元数据填充程序

将我原先存在的项目升级到Angular 4和Angular/CLI 1.0后,我收到此错误:

core.es5.js:354 Uncaught reflect-metadata shim is required when using class decorators
Run Code Online (Sandbox Code Playgroud)

我把我的项目比作新鲜的ng new,它们在配置上看起来很相似.我重新启动了终端和计算机.删除node_modules,npm cache clean,npm prune,npm i

我在Windows 7上运行

版本1.0.0上的CLI没有错误,ng build但是当我运行应用程序时,我在浏览器中收到错误.我在https://angular-update-guide.firebaseapp.com/的帮助下从版本rc.2和Angular从v2.5升级CLI


*更新

我发现我index.scala.html没有它的脚本标签polyfills.js.挂起那部分之后我产生了这个错误:

Uncaught RangeError: Maximum call stack size exceeded
Run Code Online (Sandbox Code Playgroud)

的package.json

{
  "name": "mikeumus",
  "version": "1.0.0",
  "description": "A webpack starter for angular 2",
  "scripts": {
    "build": "ng build -dev -e dev",
    "build:aot": "ng build -prod -e prod --aot true --sourcemap false", …
Run Code Online (Sandbox Code Playgroud)

reflect-metadata angular-cli angular

10
推荐指数
2
解决办法
7141
查看次数

angular-cli自定义原理图/集合

我正在尝试为角度cli创建自定义原理图.到目前为止,我已经想通了"集合"必须编译,cli无法读取打字稿.这意味着您不能只是克隆https://github.com/angular/devkit/tree/master/packages/schematics/angular更改您需要的内容并将其发布到npm,这意味着您需要克隆整个https:// github.com/angular/devkit并使用它npm run build来创建您需要通过tsc运行它的编译原理图,然后您可以将这些编译的文件发布到npm并使用npm进行全局安装,例如

npm i -g @thescrollbar/schematics

然后我应该能够做到,ng new --collection=@thescrollbar/schematics my-app但令人惊讶的是,它没有用,并且正在投掷tree.branch is not a function.

但是如果将这个全局安装的包复制到cli的模块中

/usr/local/bin/node_modules/@thescrollbar/schematics - > /usr/local/bin/node_modules/@angular/cli/node_modules/@thescrollbar/schematics

它开始工作,你可以创建一个基于你的原理图的新应用程序..

现在,对于新问题,当我尝试使用生成新组件时,我没有解决方法

ng g c --collection=@thescrollbar/schematics logo

它使用@schematics/angular模板创建它,而不是我的集合,尽管事实上,当我故意这样做

ng g shat --collection=@thescrollbar/schematics logo

它说

在集合"@ thescrollbar/schematics"中找不到原理图"shat".

我认为这清楚地表明它确实在使用我的收藏品?

有人设法让自定义集合工作吗?全球和生成组件/模块?

angular-cli angular angular-schematics

10
推荐指数
1
解决办法
4408
查看次数

在angular5中添加第三方(外部)js lib的问题

我正在使用angular 5应用程序(Angular CLI:1.6.1)添加jsplumb社区js库版本.

使用没有任何配置tsconfig.json的第一个生成我得到以下错误.

ERROR in src/app/jsplumb/jsplumb.component.ts(4,25): error TS6143: Module '../../../node_modules/jsplumb/dist/js/jsplumb.js' was resolved to 'D:/myproj/angular5/myapp/node_modules/jsplumb/dist/js/jsplumb.js', but '--allowJs' is not set.
Run Code Online (Sandbox Code Playgroud)

使用"allowJs":tsconfig.json中的true会出现以下错误

ERROR in error TS5055: Cannot write file 'D:/myproj/angular5/myapp/node_modules/jsplumb/dist/js/jsplumb.js' because it would overwrite input file.
  Adding a tsconfig.json file will help organize projects that contain both TypeScript and JavaScript files. Learn more at https://aka.ms/tsconfig.
Run Code Online (Sandbox Code Playgroud)

根据tsconfig FAQ

为什么我收到错误TS5055:无法写入文件'xxx.js',因为它会覆盖输入文件.

使用outDir("outDir":"./ dist/out-tsc")此问题应该得到解决.这已在我的tsconfig中设置.

如果我们将noEmit添加到true它只是构建应用程序,不包括任何js我们得到一个空白的白色屏幕.

让我知道是否有人试图用新的角度cli包含外部js并面临同样的错误,同样的解决方案是什么.

没有任何附加选项添加到tsconfig.json,如果我尝试修改任何ts文件,应用程序将成功编译,我能够工作.但是,在运行ng build时,这无助于创建可部署的二进制文件.

更新解决方法:直到CLI中的修复程序可用.对于开发(ng serve),从tsconfig.json中删除allowJs,当你因添加allowJs而出错时只需修改一个ts文件来重新编译应用程序,这次将成功编译.对于生产或分发,将allowJs添加回tsconfig.json运行应用程序运行,ng build --prod --watch=auto你应该看到有关覆盖node_module中的JS文件的错误,简单修改它应该重建的ts文件,因为--watch = auto在命令中但是这个成功的时间.

javascript npm typescript angular-cli angular5

10
推荐指数
1
解决办法
849
查看次数

无法运行新的Angular CLI项目

我有一份面试的家庭作业.它需要在Angular中完成,所以我想在开始之前我会快速升级Node.js,NPM和Angular CLI.看起来这是一个坏主意.

在运行我的命令之后:ng new project-name --style scss一切似乎都很好.但是当我运行时,ng serve我收到以下错误:

Cannot find module 'uglifyjs-webpack-plugin'
Error: Cannot find module 'uglifyjs-webpack-plugin'
    at Function.Module._resolveFilename (module.js:555:15)
    at Function.Module._load (module.js:482:25)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/andybarratt/dev/project-name/node_modules/@angular/cli/models/webpack-
configs/production.js:13:24)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
    at tryModuleLoad (module.js:513:12)
    at Function.Module._load (module.js:505:3)
    at Module.require (module.js:604:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/andybarratt/dev/project-name/node_modules/@angular/cli/models/webpack-
configs/index.js:9:10)
    at Module._compile (module.js:660:30)
    at Object.Module._extensions..js (module.js:671:10)
    at Module.load (module.js:573:32)
Run Code Online (Sandbox Code Playgroud)

我无法在任何地方找到任何涉及Angular的错误.正如我所说,这是一个完全干净的项目; 我还没有开始编码.

跑步ng --version给了我这个:

    _                      _                 ____ …
Run Code Online (Sandbox Code Playgroud)

npm angular-cli angular

10
推荐指数
2
解决办法
3016
查看次数