与 Angular 14 生成的项目类似,我希望拥有单独的开发和生产环境,但在创建项目时使用ng new
:
ng new my-app
Run Code Online (Sandbox Code Playgroud)
这不会创建环境文件夹或对其进行设置。
我刚刚完成了Angular CLI的全新安装,以便尝试一下,我不知道在命令行上导致以下错误的原因:
PC:cobros Fran$ ng serve
** NG Live Development Server is listening on localhost:4200, open your browser on http://localhost:4200/ **
95% emitting/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40
callbacks[i](err, result);
^
TypeError: callbacks[i] is not a function
at Storage.finished (/Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:40:15)
at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/enhanced-resolve/lib/CachedInputFileSystem.js:77:9
at /Users/Fran/Documents/Workspace/Repos/cobros/node_modules/graceful-fs/polyfills.js:287:18
at FSReqWrap.oncomplete (fs.js:153:5)
Run Code Online (Sandbox Code Playgroud)
这是我在尝试"ng -v"时返回的信息(如果它有用的话):
Angular CLI: 1.6.8
Node: 8.9.0
OS: darwin x64
Angular: 5.2.4
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
@angular/cli: 1.6.8
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.9.8 …
Run Code Online (Sandbox Code Playgroud) 我已经使用命令 npm install -g @angular/cli 安装了 angular-cli。当我尝试运行命令 ng new 并创建新项目时,出现错误:
\n\xe2\xa0\x99 Installing packages (npm)...npm WARN deprecated source-map-resolve@0.6.0: See https://github.com/lydell/source-map-resolve#deprecated\nnpm ERR! code E404\nnpm ERR! 404 Not Found - GET https://registry.npmjs.org/@types/eslint/-/eslint-8.4.4.tgz - Not found\nnpm ERR! 404 \nnpm ERR! 404 '@types/eslint@https://registry.npmjs.org/@types/eslint/-/eslint-8.4.4.tgz' is not in this registry.\nnpm ERR! 404 You should bug the author to publish it (or use the name yourself!)\nnpm ERR! 404 \nnpm ERR! 404 Note that you can also install from a\nnpm ERR! 404 tarball, folder, http url, or git …
Run Code Online (Sandbox Code Playgroud) 我正在重新安装我的 MacBook。我在安装 (npm install -g @angular/cli) angular 时收到以下消息。知道为什么吗?我怀疑 nom 版本,但我和 node 一起来了...
Developments npm install -g @angular/cli
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular/cli@11.1.4',
npm WARN EBADENGINE required: { node: '>= 10.13.0', npm: '^6.11.0', yarn: '>= 1.13.0' },
npm WARN EBADENGINE current: { node: 'v15.8.0', npm: '7.5.2' }
npm WARN EBADENGINE }
npm WARN EBADENGINE Unsupported engine {
npm WARN EBADENGINE package: '@angular-devkit/architect@0.1101.4',
npm WARN EBADENGINE required: { node: '>= 10.13.0', npm: '^6.11.0', yarn: '>= 1.13.0' …
Run Code Online (Sandbox Code Playgroud) 我使用最新的 Angular 版本在我的计算机上本地设置了 Angular 项目,每当我使用 CLI 命令作为 ng 服务运行该项目时,它都会首先以红色显示错误“这是一个用于测试或调试 Angular 应用程序的简单服务器”本地。尚未经过安全问题审查。
不要将其用于生产!”但最后,全部编译成功。
我的问题是,为什么每当我在本地计算机上使用“ngserve”运行我的角度项目时,就会出现此错误。请详细解释一下。是否有任何配置问题?我们是否需要对角度设置进行任何更改以避免将来出现此类错误?
我已经使用了这个 msSaveOrOpenBlob 方法。它工作正常,但将打字稿更新到最新版本后,我收到多个错误,有两个错误。
window.navigator.msSaveOrOpenBlob(数据, 文件名);
错误 TS2322:类型“Promise<>”无法分配给类型“IPromise<>”。
解决办法是什么?
我正在将角度 5 更新为 6V。
我按照指南中的所有步骤进行操作 - https://update.angular.io/?v=5.2-6.0
ng version
Angular CLI: 6.2.9
Node: 14.15.5
OS: linux x64
Angular: 6.1.10
... animations, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, router
Package Version
-----------------------------------------------------------
@angular-devkit/architect 0.6.8
@angular-devkit/build-angular 0.6.8
@angular-devkit/build-optimizer 0.6.8
@angular-devkit/core 0.6.8
@angular-devkit/schematics 0.8.9
@angular/cdk 5.2.5
@angular/cli 6.2.9
@angular/material 5.2.5
@angular/platform-server 5.2.10
@ngtools/webpack 6.0.8
@schematics/angular 0.8.9
@schematics/update 0.8.9
rxjs 6.0.0
typescript 2.9.2
webpack 4.8.3
Run Code Online (Sandbox Code Playgroud)
现在,当我运行时, ng serve
我收到一条关于我的@type的大错误消息
例子:
ERROR in node_modules/@types/babel__traverse/index.d.ts(68,50): error TS1005: ']' expected.
node_modules/@types/babel__traverse/index.d.ts(68,53): error …
Run Code Online (Sandbox Code Playgroud) 我正在使用 Angular 14、Node 16 和 TypeScript。我工作正常,但是现在当我执行 ngserve 命令时,出现以下错误:
./src/main.ts - Error: Module build failed (from ./node_modules/@ngtools/webpack/src/ivy/index.js):
Error: Maximum call stack size exceeded
Run Code Online (Sandbox Code Playgroud)
这是我的 ng 版本
我正在使用 Angular 来使用“ https://coursetro.com/posts/code/171/Angular-7-Tutorial---Learn-Angular-7-by-Example ”中的示例来构建此应用程序。它是一个确切的代码,但我仍然收到“user:Object”
的错误
我该如何修复这个错误?
错误 TS2564:属性“users”没有初始值设定项,并且未在构造函数中明确分配。
12个用户:对象;~~~~~~
Here is the exact code as per website:
import { Component, OnInit } from '@angular/core';
import { DataService } from '../data.service';
@Component({
selector: 'app-home',
templateUrl: './home.component.html',
styleUrls: ['./home.component.scss']
})
export class HomeComponent implements OnInit {
//h1Style:boolean = false;
users: Object;
constructor(private data: DataService) { }
ngOnInit(): void {
this.data.getUsers().subscribe(data => {
this.users = data
console.log(this.users);
}
);
}
}
Run Code Online (Sandbox Code Playgroud)
我的 Angular 基于 ng 版本:Angular CLI:11.1.2
节点:14.15.4
操作系统:win32 x64
角度:11.1.1 …
错误:无法启动连接:错误:WebSocket 连接失败。在服务器上找不到连接,端点可能不是 SignalR 端点,服务器上不存在连接 ID,或者存在阻止 WebSocket 的代理。如果您有多个服务器,请检查粘性会话是否已启用。
WebSocketTransport.js:49 WebSocket 连接到“ws://xxxxxx/product/web-services/hubs/spreadhub”失败:
Angular.ts
ngOnInit(): void {
// For signalR Hub connection
this.connection = new HubConnectionBuilder()
.withUrl('http://xxx.xxx.com/production/web-services/hubs/spreadhub', { // localhost from **AspNetCore3.1 service**
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.build();
this.connection.on('dataReceived', (data: string) => {
var model = JSON.parse(data);
});
this.connection.start().then(() => { // to start the server
console.log('server connected!!!');
}).catch(err => console.log(err));
}
Run Code Online (Sandbox Code Playgroud) angular-cli ×6
angular ×4
npm ×4
typescript ×4
node.js ×2
asp.net-core ×1
javascript ×1
macos ×1
npm-install ×1
signalr ×1