运行时出现错误ng build--prod。而且我也尝试运行,npm install但我也遇到了同样的错误。
ERROR in Module build failed: TypeError: Cannot read property 'replace' of undefined
at normalizeBackSlashDirection (D:\angular\blog\node_modules\webpack\lib\RequestShortener.js:15:17)
at new RequestShortener (D:\angular\blog\node_modules\webpack\lib\RequestShortener.js:25:15)
at new Compiler (D:\angular\blog\node_modules\webpack\lib\Compiler.js:136:27)
at Compiler.createChildCompiler (D:\angular\blog\node_modules\webpack\lib\Compiler.js:371:25)
at Compilation.createChildCompiler (D:\angular\blog\node_modules\webpack\lib\Compilation.js:1851:24)
at Object.pitch (D:\angular\blog\node_modules\mini-css-extract-plugin\dist\loader.js:70:43)
Run Code Online (Sandbox Code Playgroud) 我是 Angular 的新手。当使用 Angular-CLI 安装 angular 应用程序时tsconfig.app.json,我遇到了这些文件,tsconfig.spec.json并从该链接中发现以下几点很有用。
两个 tsconfig.*.json 文件都用于 TypeScript 配置。tsconfig.app.json 用于编译代码,而 tsconfig.spec.json 用于编译测试。
我的疑问是,tsconfig.spec.json如果我们不使用任何测试环境,我们可以完全排除文件吗?还是tsconfig.spec.json强制性的?
是否可以使用 Angular CLI (7.0.5) 为开发和生产提供不同的资产?
对于生产,我想要资产:
"assets": [
"projects/example/src/favicon.ico"
]
Run Code Online (Sandbox Code Playgroud)
对于开发,我想要资产:
"assets": [
"projects/example/src/favicon.ico",
"projects/example/src/assets/development.css"
]
Run Code Online (Sandbox Code Playgroud)
先感谢您。
大约 50% 的托管构建失败,出现 npm 错误 134。我正在使用托管 vs2017 构建具有相同构建定义的相同提交。我正在使用 Angular CLI 构建一个 Angular 应用程序。npm 任务调用“run build”,它在我的 package.json 中定义为“ng build --prod”。成功的构建和失败的构建都使用 npm 任务版本 1.1.49 和 npm 版本 6.8。这让我相信它与托管环境有关。托管的 vs2017 和 vs2019 代理几乎总是失败。而 Windows 容器代理失败的时间大约为 50%。
npm ERR! code ELIFECYCLE
npm ERR! errno 134
npm ERR! my-app@1.0.0 build: `ng build --prod`
npm ERR! Exit status 134
npm ERR!
npm ERR! Failed at the my-app@1.0.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above. …Run Code Online (Sandbox Code Playgroud) node.js angular-cli azure-pipelines-build-task azure-pipelines angular
当我运行 npm audit 命令时
=== npm 审计安全报告 ===
`Manual Review
Some vulnerabilities require your attention to resolve
Visit https://go.npm.me/audit-guide for additional guidance `
High ? Arbitrary File Overwrite
Package ? tar
Patched in ? >=4.4.2
Dependency of ? @angular-devkit/build-angular [dev]
Path ? @angular-devkit/build-angular > node-sass > node-gyp >tar
More info ? https://nodesecurity.io/advisories/803
Run Code Online (Sandbox Code Playgroud)
它的说法found 1 high severity vulnerability in 42611 scanned packages
1 vulnerability requires manual review。由于它与 相关@angular-devkit/build-angular,我担心它是否会在我的项目中产生任何其他问题。
当我运行 npm audit fix 命令时
npm WARN optional SKIPPING …Run Code Online (Sandbox Code Playgroud) 我有一个用于演示目的的角度模块(DevShowcaseModule)。此模块不应包含在生产版本中。为了向最终用户隐藏此演示并防止生产中的演示代码错误。
环境:
这是我的 app-routing.module.ts
{
path: APP_NAV_ITEMS.DEV_SHOWCASE,
canActivate: [ AuthGuard ],
loadChildren: './_dev-showcase/dev-showcase.module#DevShowcaseModule',
}
Run Code Online (Sandbox Code Playgroud)
我试图从 tsconfig.json 中排除模块文件夹。但它不起作用,我仍然可以调用路由并加载演示模块。
{
"compileOnSave": false,
"compilerOptions": {
"baseUrl": "./",
"importHelpers": true,
"outDir": "./dist/out-tsc",
"sourceMap": true,
"declaration": false,
"module": "es2015",
"moduleResolution": "node",
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"noUnusedLocals": true,
"noUnusedParameters": true,
"target": "es5",
"typeRoots": [
"node_modules/@types"
],
"lib": [
"es2018",
"dom"
]
},
"exclude": [
"app/_dev-showcase/*"
]
}
Run Code Online (Sandbox Code Playgroud)
知道如何正确地做到这一点吗?
谢谢!
当我构建我的 angular 项目时,我看到
main-es5.js和main-es2015.js 两个文件。我只想支持 Chrome 浏览器如何关闭构建旧的 js 文件我希望 Build.js 上的文件数量最少。
自从我升级到 8 以来,我的 Build 也运行了两次
笔记
构建时间显着增加,我在预算中收到警告警告,初始超出最大值。
这是我的Angular.json文件
"optimization": true,
"outputHashing": "none",
"sourceMap": true,
"extractCss": false,
"namedChunks": false,
"showCircularDependencies": false,
"aot": true,
"extractLicenses": false,
"statsJson": false,
"progress": true,
"vendorChunk": false,
"buildOptimizer": true,
Run Code Online (Sandbox Code Playgroud)
浏览器列表文件
# This file is used by the build system to adjust CSS and JS output to support the specified browsers below.
# For additional information regarding the format and rule options, please …Run Code Online (Sandbox Code Playgroud) Asp.net 核心 2.1 + Angular 6 应用程序。在我的Start.cs档案里。我们有
app.UseSpa(spa =>
{
// To learn more about options for serving an Angular SPA from ASP.NET Core,
// see https://go.microsoft.com/fwlink/?linkid=864501
spa.Options.SourcePath = "ClientApp";
if (env.IsDevelopment())
{
spa.UseAngularCliServer(npmScript: "start");
}
});
Run Code Online (Sandbox Code Playgroud)
早上,我从 Visual Studio 运行了 asp.net 核心应用程序(单击 F5)。我让 webpack 构建卡在构建模块上。它构建了一个 scss 文件很长时间并挂在那里。所以网页抛出了asp.net core中间件异常。
但是在下午,我遇到了不同的错误。这是Fail: Microsoft.AspNetCore.SpaServices[0].
但是,如果我npm start在命令窗口中运行,则dotnet run在 Visual Studio 代码中运行。没事。
告诉我该怎么做?
将 angular 7 更新为 angular 8,我angular/cli angular/core使用命令成功更新$ ng update @angular/cli@v8 @angular/core@v8。而且我也使用了有角度的材料,所以我想更新材料,然后我用$ ng update @angular/material@v8. 但是在运行命令后我得到了Repository is not clean. Please commit or stash any changes before updating.
所以我在更改 git 之前提交,然后我再次尝试使用相同的命令,然后也得到相同的消息。现在没有要提交或存储的文件。
这是package.json文件的依赖关系:
"dependencies": {
"@angular/animations": "^8.0.0",
"@angular/cdk": "^7.3.7",
"@angular/common": "^8.0.0",
"@angular/compiler": "^8.0.0",
"@angular/core": "^8.0.0",
"@angular/forms": "^8.0.0",
"@angular/material": "^7.3.7",
"@angular/platform-browser": "^8.0.0",
"@angular/platform-browser-dynamic": "^8.0.0",
"@angular/router": "^8.0.0",
"core-js": "^2.5.4",
"hammerjs": "^2.0.8",
"ngx-loading": "^3.0.1",
"rxjs": "6.5.2",
"underscore": "^1.9.1",
"zone.js": "~0.9.1"
},
"devDependencies": {
"@angular-devkit/build-angular": "~0.800.0",
"@angular/cli": "~8.0.2", …
我有一个在 centos 7 容器上运行的 jenkins 工作。一旦容器启动,jenkins 作业就会运行一个脚本来执行
npm install -g @angular/cli
Run Code Online (Sandbox Code Playgroud)
这已经工作了大约一年,但今天它开始失败:
/usr/bin/ng -> /usr/lib/node_modules/@angular/cli/bin/ng
> @angular/cli@8.0.4 postinstall /usr/lib/node_modules/@angular/cli
> node ./bin/postinstall/script.js
/usr/lib/node_modules/@angular/cli/bin/postinstall/analytics-prompt.js:8
(async () => {
^
SyntaxError: Unexpected token (
at createScript (vm.js:56:10)
at Object.runInThisContext (vm.js:97:10)
at Module._compile (module.js:549:28)
at Object.Module._extensions..js (module.js:586:10)
at Module.load (module.js:494:32)
at tryModuleLoad (module.js:453:12)
at Function.Module._load (module.js:445:3)
at Module.require (module.js:504:17)
at require (internal/module.js:20:19)
at Object.<anonymous> (/usr/lib/node_modules/@angular/cli/bin/postinstall/script.js:5:1)
npm ERR! Linux 3.10.0-957.1.3.el7.x86_64
npm ERR! argv "/usr/bin/node" "/usr/bin/npm" "install" "-g" "@angular/cli"
npm ERR! node v6.16.0
npm ERR! …Run Code Online (Sandbox Code Playgroud) angular-cli ×10
angular ×7
typescript ×2
webpack ×2
angular8 ×1
asp.net-core ×1
devkit ×1
git ×1
github ×1
html ×1
ng-build ×1
node.js ×1
npm ×1
production ×1
unit-testing ×1