当我在--prod --aot模式下构建角度项目时,出现此错误:
“属性‘X’是私有的,只能在类内访问
我如何设置我的应用程序以在“ngserve”模式下显示此错误?
我有一个角度运行,确实在某个路径下运行,例如 https://host:port/path/
当我加载应用程序并运行 ngsw-cache-bust 时,它会忽略路径并尝试直接从根路径https://host:port/script.js获取脚本,而不是从https://host:port/获取脚本路径/script.js
我通过运行 ng add @angular/pwa 添加了 pwa
我尝试了几种注册方法,例如 /ngsw-worker.js 或 ./ngsw-worker.js,但这些方法似乎都无法修复它
我们使用 Angular 7.2.0
ngsw-config.json 看起来像这样
`
{
"index": "/index.html",
"routes": {
"/": {
"prefix": false
},
"/scripts": {
"prefix": true
},
"/libraries": {
"prefix": true
}
},
"assetGroups": [
{
"name": "app",
"installMode": "prefetch",
"resources": {
"files": [
"./favicon.ico",
"./index.html",
"./*.css",
"/**.js"
]
}
}, {
"name": "assets",
"installMode": "lazy",
"updateMode": "prefetch",
"resources": {
"files": [
"/assets/**",
"/*.(eot|svg|cur|jpg|png|webp|gif|otf|ttf|woff|woff2|ani)"
],
"urls": [
"https://fonts.googleapis.com/**" …Run Code Online (Sandbox Code Playgroud) 我有一个有角度的 (7) 项目。
在我的 package.json 中,我定义了一个命令:
{
"name": "xxx",
"version": "0.1.0",
"scripts": {
"ng": "ng",
"start": "ng serve",
"build": "ng build",
"build-prod": "ng build --prod",
"test": "ng test",
"test-ci": "ng test --no-watch --no-progress --browsers=ChromeHeadlessNoSandbox",
"e2e-ci": "ng e2e --protractor-config=e2e/protractor.conf.js",
"deploy": "firebase deploy --token $FIREBASE_TOKEN --non-interactive",
"lint": "ng lint",
"e2e": "ng e2e"
},
[...]
}
Run Code Online (Sandbox Code Playgroud)
当我npm run build-prod在本地运行时,一切都很好。
现在我尝试在我的 gitlab CI 上执行此代码。
为此我有以下内容.gitlab-ci.yml
image: node:10
build:
stage: build
cache:
paths:
- node_modules/
script:
- npm install --quiet
- npm …Run Code Online (Sandbox Code Playgroud) 安装软件包后我收到此消息:
added 1 package from 8 contributors and audited 49729 packages in 23.754s
found 25 vulnerabilities (1 low, 24 high)
run `npm audit fix` to fix them, or `npm audit` for details
Run Code Online (Sandbox Code Playgroud)
所以我运行npm audit fix并修复了一些漏洞。
...
+ @angular-devkit/build-ng-packagr@0.800.2
+ @angular-devkit/build-angular@0.800.2
added 125 packages from 72 contributors, updated 8 packages and moved 16 packages in 65.005s
fixed 12 of 25 vulnerabilities in 49729 scanned packages
3 package updates for 13 vulns involved breaking changes
(use `npm audit fix --force` …Run Code Online (Sandbox Code Playgroud) 根据 angular-cli 文档,BuilderContext.reportStatus()应该用于报告构建器活动的状态,但我什么也没看到(使用"@angular-devkit/architect": "^0.802.0"),而BuilderContext.logger.info()确实将状态输出到控制台,所以我对如何使用 reportStatus 功能完全感到困惑。
我想从角度 7 更新到角度 8。这就是我所做的。首先我跑了yarn upgrade --latest。我注意到这会给我 typescript 3.6.3,这对于 Angular 来说太新了,所以我将其降级到 3.5.3。现在,当我尝试运行我的应用程序时,我收到很多错误(例如 @ViewChild 缺少参数)
所以,我想,这可以通过以下方式解决ng update -all:
$> ng update --all
Using package manager: 'yarn'
Collecting installed dependencies...
Found 66 dependencies.
Package "@angular/compiler-cli" has an incompatible peer dependency to "typescript" (requires ">=3.4 <3.6", would install "3.6.3").
Incompatible peer dependencies found.
Peer dependency warnings when installing dependencies means that those dependencies might not work correctly together.
You can use the '--force' option to ignore incompatible peer dependencies and …Run Code Online (Sandbox Code Playgroud) 我使用的是 Mac,目前安装了 Angular 8 版本。
我想升级到 Angular 9,所以我这样做了:
npm uninstall -g angular-cli
npm cache clean or sudo npm cache verify
npm install -g @angular/cli@latest
Run Code Online (Sandbox Code Playgroud)
我没有犯错误,但是当我这样做时
ng--版本
这是回归版本8。
如何更新到版本 9?
single-page-application angular-cli angular angular8 angular9
我正在尝试配置 custom-webpack.config.js 以使用 copyWebpackPlugin 将一些图标从库移动到我的资产,我已经创建了我的 custom-webpack.config.js 文件,这是我在 angular.json 中的配置:
"architect": {
"build": {
"builder": "@angular-builders/custom-webpack:browser",
"options": {
"customWebpackConfig":{
"path":"./custom-webpack.config.js",
"replaceDuplicatePlugins":true
},
Run Code Online (Sandbox Code Playgroud)
和
"serve": {
"builder": "@angular-builders/custom-webpack:dev-server",
"options": {
"browserTarget": "myProject:build"
},
Run Code Online (Sandbox Code Playgroud)
但是当运行 ngserve 或 ngbuild 时,我收到此错误:
Job name "..getProjectMetadata" does not exist.
Error: Job name "..getProjectMetadata" does not exist.
Run Code Online (Sandbox Code Playgroud)
这些是我的 Angular 库:
"@angular/animations": "^8.0.0",
"@angular/cdk": "^8.0.1",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/forms": "^8.0.0",
"@angular-builders/custom-webpack": "^9.0.0",
"@angular-builders/dev-server": "^7.3.1",
"@angular-devkit/build-angular": "^0.803.23",
"@angular/cli": "8.0.0",
"@angular/compiler-cli": "^8.0.0",
"@angular/language-service": "^8.0.0",
Run Code Online (Sandbox Code Playgroud)
有任何想法吗?
使用 @angular/cli 几天后,ng 突然无法再访问。我没有碰任何东西来让这件事发生。
到目前为止我已经尝试过:
卸载并重新安装@angular/cli
全局安装后,@angular/cli 和 ng 都不在我的 /Users//.npm-global 或我的 /Users//.npm-global 目录中。
设置和重置 $PATH(如下)
/Users//.npm-global/bin:/Users//.npm-packages/bin:
将 ~/.npm-global 添加到我的 /etc/paths 文件中
但我仍然没有成功访问 ng 命令。这真是令人沮丧。为什么我的计算机不再识别它一天前未经激怒才使用的东西?我该如何解决这个问题?这不是第一次发生这种情况。
npm 版本:6.14.4
节点版本:v.14.0.0
macOS Catalina:10.15.4
我想在角度组件中使用类型脚本函数显示格式化的 HTML,我希望它显示不同类型的问题,我尝试了这个,
\n\nimport {Component, OnInit} from \'@angular/core\';\nimport {TP, Question, Qtype} from "../tp";\nimport * as Exercice from \'../assets/Exercice.json\';\n\n@Component({\n selector: \'app-tp\',\n templateUrl: \'./tp.component.html\',\n styleUrls: [\'./tp.component.css\']\n})\nexport class TpComponent implements OnInit {\n\n\n constructor() {\n }\n\n ngOnInit(): void {\n }\n\n displayQCM(question: Question) {\n return `\n <div>\n <hr class="w-100">\n <h3>Question n\xc2\xb0${question.number} ${question.questionType}</h3>\n <p>${question.questionContent}</p>\n ...\n QCM question element\n ...\n </div>\n `;\n }\n\n displayTrueOrFalse(question: Question) {\n return `\n <div>\n <hr class="w-100">\n <h3>Question n\xc2\xb0${question.number} ${question.questionType}</h3>\n <p>${question.questionContent}</p>\n ...\n true or false question element\n ...\n </div>\n `;\n }\n\n displayQuestion(question: Question) …Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×8
angular8 ×1
angular9 ×1
command-line ×1
gitlab ×1
gitlab-ci ×1
html ×1
npm ×1
npm-install ×1
typescript ×1
webpack ×1