更新到 Angular 15 后,我的构建过程
"build:project:prod": "ng build project --configuration prod --stats-json=true --single-bundle=true && npm run copyAssets"
Run Code Online (Sandbox Code Playgroud)
构建后没有退出,所以copyAssets甚至不启动。在终端中,我看到一个包含块文件和一行的表
Build at: 2023-02-03T15:44:54.029Z - Hash: 5837a5d758832c93 - Time: 7163ms
Run Code Online (Sandbox Code Playgroud)
整个管道因此而崩溃。如何保证整个脚本正确执行?
这是我的独立组件
import { Component } from '@angular/core';
import { CommonModule } from '@angular/common';
@Component({
selector: 'app-navbar',
standalone: true,
imports: [CommonModule],
templateUrl: './navbar.component.html',
styleUrls: ['./navbar.component.scss']
})
export class NavbarComponent {
}
Run Code Online (Sandbox Code Playgroud)
这就是我导入它的地方(在管理模块中)
import { NgModule } from '@angular/core';
import { CommonModule } from '@angular/common';
import { AdminRoutingModule } from './admin-routing.module';
import { UsersComponent } from './users/users.component';
import { NavbarComponent } from '../components/navbar/navbar.component';
@NgModule({
declarations: [
UsersComponent
],
imports: [
CommonModule,
AdminRoutingModule,
NavbarComponent,
]
})
export class AdminModule { }
Run Code Online (Sandbox Code Playgroud)
在我的 usercomponent.html …
Angular 15:错误发生意外错误:“无法找到要在 c:path\node_module 中链接的 webpack-dev-server 副本。我正在尝试使用纱线安装包依赖项,但出现上述错误。该项目前段时间安装和构建得很好,但是,最近它要求使用 webpack-dev-server,而我没有在其他 Angular 项目中明确配置它,想知道它的作用是什么以及为什么它现在问我。提前寻求帮助和意见。
包.json
{
"name": "@website",
"version": "0.0.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"watch": "ng build --watch --configuration development",
"test": "ng test",
"lint": "ng lint",
"lint:staged": "lint-staged",
"lint:styles": "./node_modules/.bin/stylelint src/**/*.scss --fix",
"e2e": "ng e2e",
"cypress:open": "cypress open",
"cypress:run": "cypress run",
"cypress:component": "cypress open --component",
"format": "yarn prettier --write .",
"prepare": "cd ../.. && husky install src/website-remote-iam/.husky"
},
"lint-staged": {
"*.{js, ts}": [
"eslint --quiet --fix"
],
"*.{json, md, …Run Code Online (Sandbox Code Playgroud) 我有一个应用程序和一个单独的库。库本身功能正常,但我在浏览器开发工具中找不到库的文件,但应用程序的文件显示了。开发工具截图
目录结构
test (non-project folder)
- test-libs (project folder)
- projects
- test-lib
- test-app (project folder)
Run Code Online (Sandbox Code Playgroud)
测试库文件
角度.json
{
"$schema": "./node_modules/@angular/cli/lib/config/schema.json",
"version": 1,
"newProjectRoot": "projects",
"projects": {
"test-lib": {
"projectType": "library",
"root": "projects/test-lib",
"sourceRoot": "projects/test-lib/src",
"prefix": "lib",
"architect": {
"build": {
"builder": "@angular-devkit/build-angular:ng-packagr",
"options": {
"project": "projects/test-lib/ng-package.json"
},
"configurations": {
"production": {
"tsConfig": "projects/test-lib/tsconfig.lib.prod.json"
},
"development": {
"tsConfig": "projects/test-lib/tsconfig.lib.json"
}
},
"defaultConfiguration": "development"
},
"test": {
"builder": "@angular-devkit/build-angular:karma",
"options": {
"tsConfig": "projects/test-lib/tsconfig.spec.json",
"polyfills": [
"zone.js",
"zone.js/testing"
]
} …Run Code Online (Sandbox Code Playgroud) debugging google-chrome-devtools typescript angular-cli angular
长话短说
我需要使用platform: 'node'Angular 应用程序来查找不再与 WebPack 5 捆绑在一起、但与 Node 捆绑在一起的模块。但我一直找不到平台设置需要放入的文件。
有人可以告诉我平台设置需要去哪里吗?请?
更多信息
我使用 Angular CLI 17.0.0 创建了一个在节点 20.9.0 上运行的 Angular 应用程序。当我尝试“ng服务”时,我看到如下消息:
在文件系统上找不到包“stream”,但它内置于节点中。您是否正在尝试捆绑节点?您可以使用“platform: 'node'”来执行此操作,这将消除此错误。
谁能告诉我platform: 'node'应该放入什么文件?我无法在 .json 或 .config.js 文件中找到分配了任何值的“平台”。
我在我的项目中使用angular-cli,我想使用全局图像 - 我的网站徽标图像.
据我所知,public项目根目录(angular-cli创建)的目录是公共资产 - 这似乎是放置我的形象的好地方(如果我错了请纠正我).
但是,当我尝试在我的<img src="/public/book4u-logo.svg" />标签中找到该图像时,我得到404.原因是,当然,我的项目根目录是src目录而不是项目根目录.
那么,我应该如何进入该目录?或者我应该将我的图像放在另一个目录中?
我的项目树(我删除不必要的后缀):
.
??? angular-cli-build.js
??? angular-cli.json
??? package.json
??? public
? ??? book4u-logo.svg
? ??? hero-image-default.jpg
??? src
? ??? app
? ? ??? bfy.component.html
? ? ??? bfy.component.scss
? ? ??? bfy.component.ts
? ? ??? environment.ts
? ??? favicon.ico
? ??? index.html
? ??? main.ts
? ??? system-config.ts
? ??? tsconfig.json
? ??? typings.d.ts
??? tslint.json
??? typings.json
Run Code Online (Sandbox Code Playgroud)
该 …
我正在尝试使用Windows 7 Pro机器上的MINGW64泊坞箱中的angular-cli构建我的角度项目.
在git bash中,我使用的命令是:
ng build --prod --base-href /appcontext/
Run Code Online (Sandbox Code Playgroud)
我想要做的是修改我的当前基本标签与属性href="/"为href="/appcontext/"
相反,我得到一个基本标签href="C:/Program Files/Git/appcontext/".
有人有什么想法?
我无法配置angular-cli + scss + karma来一起测试我的组件.运行ng testkamra单元测试仅包括组件自己的scss样式.
为了在测试中应用我的主要styles.scss,我尝试在karma.conf.js中配置它们:
files: [
{ pattern: './src/test.ts', watched: false },
{ pattern: './src/styles.scss' }, // main scss
{ pattern: './src/test.css' }, // just some test css to see if it is working
]
preprocessors: {
'./src/test.ts': ['@angular/cli'],
'./src/styles.scss': [ '@angular/cli' ]
}
Run Code Online (Sandbox Code Playgroud)
在业力测试期间仍未包括主要scss.但组件拥有scss和全局css.
我怎样才能使它工作?
在Maven(Java)中,有可能构建具有不同“配置文件”的Webapp War,例如,“配置文件”指示要放入配置文件的Web服务的URL。因此,“测试配置文件”将指示与“生产配置文件”不同的URL。
是否有类似于ng build的配置文件?
我使用棱角4,角度cli.使用默认生成的配置文件.该框架正在生成不需要的锚标签.我试图将其显示为纯文本.我的template.html中的这一行:
someExampleSite.com
Run Code Online (Sandbox Code Playgroud)
当在浏览器中提供时,它变为:
<a class="vglnk" href="http://someExampleSite.com" rel="nofollow">
<span>someExampleSite</span>
<span>.</span>
<span>com</span>
</a>
Run Code Online (Sandbox Code Playgroud)
有办法解决这个问题吗?我只想在页面上将someExampleSite.com显示为纯文本.
angular ×10
angular-cli ×10
javascript ×2
typescript ×2
webpack ×2
debugging ×1
karma-runner ×1
ng-build ×1
node.js ×1
npm ×1
package.json ×1
sass ×1