x
标记)- [x] bug report -> please search issues before submitting
- [ ] feature request
_ _ ____ _ ___
/ \ _ __ __ _ _ _| | __ _ _ __ / ___| | |_ _|
/ △ \ | '_ \ / _` | | | | |/ _` | '__| | | | | | |
/ ___ \| | | | (_| | |_| | | (_| | | | |___| |___ | |
/_/ \_\_| |_|\__, |\__,_|_|\__,_|_| \____|_____|___|
|___/
@angular/cli: 1.2.3
node: 6.11.1
os: darwin x64
@angular/animations: 4.3.1
@angular/common: 4.3.1
@angular/compiler: 4.3.1
@angular/core: 4.3.1
@angular/forms: 4.3.1
@angular/http: 4.3.1
@angular/platform-browser: 4.3.1
@angular/platform-browser-dynamic: 4.3.1
@angular/router: 4.3.1
@angular/cli: 1.2.3
@angular/compiler-cli: 4.3.1
@angular/language-service: 4.3.1
$ ng new hello
$ cd hello
$ ng build --prod
$ ng build --prod
Hash: edf6fb3ccb1b82fa940c
Time: 10775ms
chunk {0} polyfills.71b130084c52939ca448.bundle.js (polyfills) 177 kB {4} [initial] [rendered]
chunk {1} main.e81f19d3f6b27a436c79.bundle.js (main) 1.09 kB {3} [initial] [rendered]
chunk {2} styles.d41d8cd98f00b204e980.bundle.css (styles) 69 bytes {4} [initial] [rendered]
chunk {3} vendor.f7457d5ac1e9743fd76f.bundle.js (vendor) 849 kB [initial] [rendered]
chunk {4} inline.18e445e37a0efd4dcfa2.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'hello/src'
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
aot 构建运行
也许,enhanced-resolve 3.4.0 是原因。
https://github.com/webpack/enhanced-resolve/issues/98
ng build --prod
在npm i [email protected]
之后成功运行。
我注意到了同样的问题,在npm i [email protected]
我可以用 AOT 构建
同样的问题在这里
@mchmielarski这是一个很好的猜测👍
同样在这里。
解决方法: npm install [email protected]
感谢您的解决方案,这个问题让我们花费了整个上午。
添加[email protected]
解决了它。
谢谢,这里也一样。
[email protected]
解决了这个问题。
和这里一样!
感谢上帝的这个问题,我解决了这个问题一整天
使用“ [email protected] ”的解决方法似乎适用于 Mac OS 但不适用于 Linux!? 任何人都可以确认这种行为吗?
适用于我的 linux ubuntu 16.04
同样的问题。
伙计们,你真的应该为 Angular-Cli 使用固定的依赖版本。 一切都崩溃了已经是百万次了,因为在新版本的子依赖项中有一些意想不到的事情......
angular-cli 版本已经为我们修复了,它是 1.3.1,但我们仍然有这个错误。
对我来说同样的问题。 在 Ubuntu 服务器上用[email protected]
解决。
RIP 我早上的前 2 个小时。
它也适用于 3.3.0。
即使使用 3.4.1,我们仍然在 AOT 中有错误。 同样在开发中,environment.ts 不会被适当的环境文件覆盖
这打破了所有构建,今天玩得很开心! PLZ PLZ PLZ 转向固定依赖。
此处[email protected]
仍然存在问题。 出现同样的问题。
现在停留在3.3.0 。
使用全新安装的 angular/cli 1.2.0 创建新项目时也会失败:(
我使用纱线进行包管理。
同样的问题在这里。 npm install [email protected]
暂时为我解决了这个问题,但只有当它作为附加安装到已经启动并运行的项目中时。 通过使用npm install
进行全新安装并在package.json
中设置此依赖项进行部署不起作用。
这是一个主要错误,因为它破坏了正在运行的部署管道以及整个生产设置。
我在 Windows 上,添加[email protected]
对我不起作用。
@mscherer82你运行npm install
吗? 如果你这样做了,你可以尝试删除node_modules
并重新运行它。 它对我有用。
@angelnikolov是的,我删除了node_modules
并重新安装了所有软件包。
嗯,你能不能试试运行npm ls
看看这是不是你的enhanced-resolve
版本+-- [email protected]
@pvanhemmen
你应该在 npm install 之后安装enhanced-resolve。 作为临时解决是可以的。
@vicetjs这就是我所做的,也是它对我
为了让我的构建服务器满意,我分叉了angular/ngtools-webpack-builds并将enhanced-resolve
在3.3.0
,然后分叉了angular/cli-builds以ngtools
叉。 如果有人感兴趣,他们可以通过将package.json
更改"@angular/cli": "github:benelliott/cli-builds#24a8837"
来尝试一下(但请注意,这两个库都将处于主版本,而不是特定版本)。
@pvanhemmen在安装[email protected]
后,我能够通过使用npm shrinkwrap
再次通过全新安装进行部署。 这让我的 Jenkins 构建管道再次正常工作
这也应该可以防止上游依赖破坏将来损害我的项目:)
@bmcswee 太棒了,
npm list
给了我:
+-- @angular/[email protected]
| +-- @ngtools/[email protected]
| +-- @ngtools/[email protected]
| | +-- [email protected]
...
| +-- [email protected]
...
| | +-- [email protected] deduped
...
+-- [email protected]
安装enhanced-resolve 3.3.0成功了,谢谢!
[email protected]对我的项目起到了作用。 有人可以解释一下这个包的作用吗?
@jakeNiemiec这意味着我应该在稍后的时间点卸载该软件包,当 Angular 团队修复该错误时,对吗?
干杯!
伙计们, [email protected]
方法不适用于我的项目。 我仍然有同样的错误。 有关于这个问题的任何更新吗?
只要是明确的(@kasperfp,@ andreasonny83):
❌ 不起作用(这是npm@^5
在我运行npm i [email protected]
时放入我的package.json
npm i [email protected]
):
"enhanced-resolve": "^3.3.0"
,
✅ 有效:
"enhanced-resolve": "3.3.0",
通过@Gustorn看到比较完整的评论如下: https://github.com/angular/angular-cli/issues/7113#issuecomment -317483817
jakeNiemiec 的评论也对我有用。 是否有针对此重大更改的任何修复计划?
大家好,
这似乎是enhanced-resolve
一个错误/重大变化,是webpack
的依赖项。 将尝试与 Webpack 维护者讨论这个问题。
同时将其固定到"enhance-resolve": "3.3.0"
中的package.json
。
编辑: enhanced-resolve
是https://github.com/webpack/enhanced-resolve/issues/98。
@filipesilva值得注意的是,它也是@ngtools/webpack
的直接依赖项。
@benelliott好点。
@lsunkara AFAIK 这将导致非 aot 构建,这可能不是每个人都想要的。
@warmans是正确的。 请参阅https://github.com/angular/angular-cli/wiki/build# --dev-vs---prod-builds 以了解--prod
标志的效果。
@bmcswee :+1: 我现在正在为所有东西添加shrinkwrap --dev。 只是需要更多的纪律,厌倦了 npm 包上的所有这些重大变化。 所以这对所有人来说都是一个很好的提示。
@warmans ,我同意, ng build --env=prod 是不可取的。 固定到增强解析到 3.3.0 仅有效。
谢谢。
enhance-resolve
repo 中的相关问题:
自 3.3.0 以来的变化。
没有什么可以为我修复这个错误。
已经尝试了此线程中编写的所有内容。
如果有人做了不同的事情,请告诉我!
@renatop7我认为这里的一些解决方法建议实际上不会在您的package.json
保存正确的版本。 这是我修复它的方法:
package.json
删除对enhanced-resolve
所有引用(如果您已经从其他解决方法中获得了一些引用)npm i -DE [email protected]
( -DE
应该在 npm4 和 npm5 之间保持一致)node_modules
文件夹以验证它是否适用于全新安装npm install
,然后运行生产构建编辑:此外,如果您使用的是npm5
我会尝试重新生成package-lock.json
(只需在第 4 步之前将其删除)。 我认为这不适用于太多人,如果您有锁定文件,构建甚至不应该损坏。
@Gustorn是一个非常好的分步指南,谢谢!
@gustorn我还必须清除我的 npm 缓存才能获得正确的版本。
@warmans您是否通过了-E
标志? 如果您要求包的特定版本(或者如果它确实弄错了,我认为这是 npm 中的错误),npm 缓存应该无关紧要。
@HirenParekh这是因为@ngtools/webpack
没有锁定enhanced-resolve
。 如果您查看1.1.1 版本中的package.json
文件,您会看到版本为^3.1.0
。 npm 在全新安装时,将安装最新的、与 semver 兼容的软件包版本,在这种情况下,它是破坏性的3.4.0
版本。
编辑:显然我回复的第二条评论被删除了。 由于解释可能对某人有用,因此问题基本上是:
为什么降级到
@angular/[email protected]
不能解决问题?
@filipesilva这是否与@yyx990803 指出的vue-cli
AoT 问题有关
https://github.com/webpack/enhanced-resolve/commit/03ef8f2b8d25bc976993eade7b1ed9caa2c7d0e1#commitcomment -23261583
编辑:明确地说, https://github.com/webpack/enhanced-resolve/pull/100 的修复不能解决这个问题。
npm i
npm i [email protected]
1.npm 清理缓存
为我解决了这个问题。
我们已经发布了1.2.4
/ 1.3.0-rc.1
来解决这个问题。 更新应完全防止此问题,无需任何其他操作。
非常感谢@sokra的快速响应和对问题的归零。
刚刚尝试使用 ^1.0.0 构建我们的项目,它更新到最新的 1.2.4 angular-cli 并解决了这个问题。
谢谢你们的快速周转。
@filipesilva在 osx 上使用 1.2.4 版,用纱线安装没有工作
和版本 1.3.0-rc.1 我看到:
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in '/Users/john/Workspace/tcabs2/ui/src'
resolve './$$_gendir/app/app.module.ngfactory' in '/Users/john/Workspace/tcabs2/ui/src'
using description file: /Users/john/Workspace/tcabs2/ui/package.json (relative path: ./src)
Field 'browser' doesn't contain a valid alias configuration
after using description file: /Users/john/Workspace/tcabs2/ui/package.json (relative path: ./src)
using description file: /Users/john/Workspace/tcabs2/ui/package.json (relative path: ./src/$$_gendir/app/app.module.ngfactory)
no extension
Field 'browser' doesn't contain a valid alias configuration
/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory.ts doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory.js doesn't exist
as directory
/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory doesn't exist
[/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory]
[/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory.ts]
[/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory.js]
[/Users/john/Workspace/tcabs2/ui/src/$$_gendir/app/app.module.ngfactory]
@ ./src/main.ts 3:0-74
@ multi ./src/main.ts
1.2.4 版适用于 npm 安装,而不适用于 yarn 安装
@mildfuzz尝试删除您的yarn.lock
,它可能会保留[email protected]
。 在下一个yarn
,它将被重建。
没有飞镖,我一直在构建之间清除 yarn.lock 和 node_modules,以确保我的 CI 服务器能够正常工作
rm -rf yarn.lock && rm -rf node_modules && yarn install && ng build -prod
不起作用
rm -rf yarn.lock && rm -rf node_modules && npm i && ng build -prod
确实有效(使用 npm 5.3.0)
此处相同:问题出现在rc.0
,似乎也出现在rc.1
。
删除 node_modules, yarn.lock + yarn cache clean
,然后从头开始重新安装所有东西 - 不能解决问题;/
PS:错误信息有所不同。 内容是一样的,但在 rc.0 上它没有缩进打印,现在它有很好的缩进;-) 由@mildfuzz 粘贴
也尝试过纱线安装。 它似乎安装了正确的 3.3.0 版本,但ng build --prod
失败了。
在我们的项目中没有使用纱线,只是出于好奇而尝试。
刚试过
npm install -g @angular/cli
ng -v
-returns version 1.2.4
npm new aottest
cd aottest
ng build --prod
工作没有失败
不使用纱线或纱线配置只是 npm
@mildfuzz @ryzy yarn list enhanced-resolve
向您展示了什么? 还有yarn why enhanced-resolve
。
@filipesilva
纱线列表 v0.27.5
└─ [email protected]
在 1.26 秒内完成。
没错,那里肯定有问题。 我们将它固定到3.3.0
所以 yarn 不应该安装3.4.1
。 你能运行yarn why enhanced-resolve
来看看它为什么会解决这个问题吗?
[1/4] 为什么我们有模块“enhanced-resolve”...?
[2/4] 初始化依赖图...
[3/4] 寻找依赖...
[4/4] 计算文件大小...
info 该模块存在的原因
- "@angular/cli#@ngtools/webpack" 依赖于它
- "@angular/cli#webpack" 依赖于它
info 不带依赖项的磁盘大小:“196kB”
info 具有唯一依赖项的磁盘大小:“328kB”
info 具有传递依赖项的磁盘大小:“820kB”
info 共享依赖项的数量:12
在 1.61 秒内完成。
yarn why enhanced-resolve
该模块存在的原因
我们的部门
"@angular/cli": "1.3.0-rc.0",
"@angular/compiler-cli": "4.1.3",
"@angular/animations": "4.1.3",
"@angular/common": "4.1.3",
"@angular/compiler": "4.1.3",
"@angular/core": "4.1.3",
"@angular/forms": "4.1.3",
"@angular/http": "4.1.3",
"@angular/platform-browser": "4.1.3",
"@angular/platform-browser-dynamic": "4.1.3",
"@angular/platform-server": "4.1.3",
"@angular/router": "4.1.3",
"rxjs": "5.4.2",
"zone.js": "0.8.14"
@thegitty我认为您在某处有一个链接的@angular/cli
...... @angular/cli
不直接依赖于enhanced-resolve
。
@coryrylan嗯,我在那里没有看到 CLI 或ngtools/webpack
。
纱线锁有
ngtools/ [email protected]
角度/[email protected]
version 3.4.1
This module exists because "@angular/cli#@ngtools/webpack" depends on it.
呃。
构建在 2 周内第二次损坏。
添加 npm install [email protected]解决了问题。
我认为要强制纱线使用某个版本,您需要在package.json
向resolutions
添加一个条目
@coryrylan您需要@angular/[email protected]
进行修复,但您在1.3.0-rc.0
。
@mildfuzz该提交确实存在,但尚未发布。 最后一次 webpack 发布是在 9 天前,但那个提交是在 13 小时前。
我试着复制粘贴你的package.json
并做纱线,它似乎安装正确:
kamik<strong i="13">@T460p</strong> MINGW64 D:/sandbox/tmp
$ yarn && yarn list enhanced-resolve && yarn why enhanced-resolve
yarn install v0.24.6
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "[email protected]" has unmet peer dependency "@ngrx/store@^2.2.1".
warning "@ngrx/[email protected]" has unmet peer dependency "@ngrx/store@^2.0.0".
[4/4] Building fresh packages...
success Saved lockfile.
Done in 66.95s.
yarn list v0.24.6
└─ [email protected]
Done in 0.87s.
yarn why v0.24.6
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Reasons this module exists
- "@angular/cli#@ngtools/webpack" depends on it
- "@angular/cli#webpack" depends on it
Done in 0.89s.
您可能遇到了纱线中的错误。 这不是第一次在解决版本时遇到问题。 我自己使用的是v0.24.6
。
@filipesilva啊谢谢! 我会试一试我应该注意到的
@filipesilva提交似乎直接提交给 master,没有 semver 更改
是的,但您没有使用 master ,您使用的是[email protected]
。 获得 master 的唯一方法是,如果你直接从 github 使用它,根据你的 package.json 你不是。
好点子。嗯,好奇
是否有任何解决方法可以使用 yarn + [email protected]
?
@cebor我处于同样的情况,但还没有找到解决办法。
我仍然在我的 linux env 上看到这个失败:
$ng -v
@角度/cli:1.2.4
节点:6.11.1
操作系统:Linux x64
@angular/common: 4.3.1
@角度/编译器:4.3.1
@角度/核心:4.3.1
@角度/表格:4.3.1
@角度/http:4.3.1
@angular/平台浏览器:4.3.1
@angular/platform-browser-dynamic: 4.3.1
@角度/路由器:4.3.1
@角度/cli:1.2.4
@angular/compiler-cli: 4.3.1
[root@4bc7c5f8560c]# 纱线列表增强-解析
纱线列表 v0.27.5
├─增强解析@3.3.0
└─ [email protected]
└─ [email protected]
在 0.62 秒内完成。
OS X 和 Linux 都有版本匹配 @angular/cli && 增强解析。 但是,在我的 alpine docker 容器上运行我得到:
./src/main.ts 中的错误
找不到模块:错误:无法解析“/godata/pipelines/XXX/src”中的“./$$_gendir/app/app.module.ngfactory”
@ ./src/main.ts 4:0-74
@多 ./src/main.ts
OS X 版本构建没有问题
我看到了一个不同的,可能是相关的问题。 我基于这个线程升级到@angular/ cli @
当我在没有 --prod 标志的情况下进行 AOT 构建时,一切都很好。 它修复了 webpack 加载问题。 尽管没有任何缓存破坏或缩小(如预期)。
$ ng build -aot -bh /app/ -d /app/
12% building modules 24/26 modules 2 active ...dh/code/skyl-sam/gui/src/polyfills.tsThe final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string
Hash: dccdd84edb379b90050e
Time: 18188ms
chunk {0} common.bundle.js, common.bundle.js.map (common) 225 kB {8} [initial] [rendered]
chunk {1} 1.chunk.js, 1.chunk.js.map 158 kB {2} {4} [rendered]
chunk {2} 2.chunk.js, 2.chunk.js.map 22.8 kB {1} {4} [rendered]
chunk {3} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 305 kB {8} [initial] [rendered]
chunk {4} main.bundle.js, main.bundle.js.map (main) 206 kB {7} [initial] [rendered]
chunk {5} styles.bundle.js, styles.bundle.js.map (styles) 12.8 kB {8} [initial] [rendered]
chunk {6} scripts.bundle.js, scripts.bundle.js.map (scripts) 935 bytes {8} [initial] [rendered]
chunk {7} vendor.bundle.js, vendor.bundle.js.map (vendor) 2.39 MB [initial] [rendered]
但是,带有--prod 的 AOT 构建会在浏览器中出错。 它告诉我找不到块。
$ ng build -aot -bh /app/ -d /app/ --prod
12% building modules 20/22 modules 2 active ...dh/code/skyl-sam/gui/src/polyfills.tsThe final argument to magicString.overwrite(...) should be an options object. See https://github.com/rich-harris/magic-string
Hash: 087aa24978df80ff0791
Time: 31614ms
chunk {0} common.c748e79cd1f1548103ca.bundle.css (common) 64.2 kB {8} [initial] [rendered]
chunk {1} 1.25adab460fca740132f8.chunk.js 156 kB {2} {4} [rendered]
chunk {2} 2.d8720a9ef943f0c023dd.chunk.js 22.8 kB {1} {4} [rendered]
chunk {3} polyfills.ff68bf59b00f20dd55fa.bundle.js (polyfills) 305 kB {8} [initial] [rendered]
chunk {4} main.84addcca1f874b2e3beb.bundle.js (main) 204 kB {7} [initial] [rendered]
chunk {5} scripts.8e25fcd212b7caba6537.bundle.js (scripts) 935 bytes {8} [initial] [rendered]
chunk {6} styles.5d90f8fb1f36b9f8617d.bundle.css (styles) 69 bytes {8} [initial] [rendered]
chunk {7} vendor.32a6e9e7149831c7fbfc.bundle.js (vendor) 2.39 MB [initial] [rendered]
chunk {8} inline.1170c1e8a9ba9c0dfcf5.bundle.js (inline) 0 bytes [entry] [rendered]
浏览器出错
ERROR Error: Uncaught (in promise): Error: Loading chunk 0 failed.
Error: Loading chunk 0 failed.
at HTMLScriptElement.n (inline.1170c1e….bundle.js:1)
at HTMLScriptElement.o (polyfills.ff68bf5….bundle.js:1)
at t.invokeTask (polyfills.ff68bf5….bundle.js:1)
at Object.onInvokeTask (vendor.32a6e9e….bundle.js:1)
at t.invokeTask (polyfills.ff68bf5….bundle.js:1)
at r.runTask (polyfills.ff68bf5….bundle.js:1)
at e.invokeTask [as invoke] (polyfills.ff68bf5….bundle.js:1)
at h (polyfills.ff68bf5….bundle.js:1)
at HTMLScriptElement.d (polyfills.ff68bf5….bundle.js:1)
at HTMLScriptElement.n (inline.1170c1e….bundle.js:1)
at HTMLScriptElement.o (polyfills.ff68bf5….bundle.js:1)
at t.invokeTask (polyfills.ff68bf5….bundle.js:1)
at Object.onInvokeTask (vendor.32a6e9e….bundle.js:1)
at t.invokeTask (polyfills.ff68bf5….bundle.js:1)
at r.runTask (polyfills.ff68bf5….bundle.js:1)
at e.invokeTask [as invoke] (polyfills.ff68bf5….bundle.js:1)
at h (polyfills.ff68bf5….bundle.js:1)
at HTMLScriptElement.d (polyfills.ff68bf5….bundle.js:1)
at a (polyfills.ff68bf5….bundle.js:1)
at a (polyfills.ff68bf5….bundle.js:1)
at polyfills.ff68bf5….bundle.js:1
at t.invokeTask (polyfills.ff68bf5….bundle.js:1)
at Object.onInvokeTask (vendor.32a6e9e….bundle.js:1)
at t.invokeTask (polyfills.ff68bf5….bundle.js:1)
at r.runTask (polyfills.ff68bf5….bundle.js:1)
at o (polyfills.ff68bf5….bundle.js:1)
at e.invokeTask [as invoke] (polyfills.ff68bf5….bundle.js:1)
at h (polyfills.ff68bf5….bundle.js:1)
_ @ vendor.32a6e9e….bundle.js:1
因此,看起来它希望生成块“0.84a03cc88aee47079f58.chunk.js”,但事实并非如此。 有没有人见过这样的事情? 非常感谢这里的任何帮助。 谢谢!
这个问题真的很烦人,花了我几个小时。 但是npm install [email protected]
在 Windows 上对我来说效果很好,不需要进一步删除或清理。
感谢您提供有用的提示!
您可以使用@angular/cli ~1.2.0 更新您的 package.json。 它将更新到最新的 1.2.4 并且您不需要安装它
@filipesilva所以我没有使用[email protected]
yarn list webpack
显示[email protected]
,其中有"enhanced-resolve": "^3.0.0",
,所以执行时会更新到 3.4.1,不是吗?
即使在[email protected]我们也没有被固定,我们有"enhanced-resolve": "^3.3.0",
@filipesilva
$ yarn list enhanced-resolve
yarn list v0.27.5
├─ @ngtools/[email protected]
│ └─ [email protected]
└─ [email protected]
Done in 0.83s.
$ yarn why enhanced-resolve
yarn why v0.27.5
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info This module exists because "webpack" depends on it.
info Disk size without dependencies: "196kB"
info Disk size with unique dependencies: "328kB"
info Disk size with transitive dependencies: "848kB"
info Number of shared dependencies: 10
Done in 0.84s.
$ yarn list webpack
yarn list v0.27.5
└─ [email protected]
Done in 0.83s.
我的整个 package.json 在这里: https :
有人对纱线用户有修复吗? 我仍然遇到错误。 甚至试图从@angular/cli": "1.2.4
降级到@angular/cli": "1.2.3
因为enhanced-resolve 似乎已经发布了一个修复程序: https :
但我仍然遇到错误。 带有以太版本。
yarn list enhanced-resolve
yarn list v0.27.5
└─ [email protected]
Done in 1.26s.
yarn why enhanced-resolve
yarn why v0.27.5
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info This module exists because "@angular/cli#@ngtools/webpack" depends on it.
Done in 2.81s.
@BorntraegerMarc将锁定到 3.3.0 的enhanced-resolve
添加到 package.json 中修复了纱线问题
@sickelap我没有使用纱线的扁平架构。 由于外部原因,这是不可能的。 或者你的意思是别的? 而且我认为不可能向resolutions
添加单个依赖项,对吗?
@BorntraegerMarc出于某种原因,yarn 将增强解析安装为根依赖项,尽管它已更新为 webpack dep 的正确版本。 所以要修复它,只需将"enhanced-resolve": "3.3.0"
到您的 package.json devDependencies 中,至少现在应该修复它。
@sickelap我将"enhanced-resolve": "3.3.0",
到 devDependencies 并运行yarn cache clean
和yarn
但我仍然遇到相同的错误。 我还删除了yarn.lock
文件。
在 yarn.lock 文件中,我仍然看到条目:
enhanced-resolve@^3.0.0:
version "3.4.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz#0421e339fd71419b3da13d129b3979040230476e"
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.4.0"
object-assign "^4.0.1"
tapable "^0.2.7"
/media/vimal/personal/future/dar-wepapp/src/app/properties-view/properties-view.component.ts 中的类型 PropertiesViewComponent 中的错误是 2 个模块声明的一部分:/media/vimal/personal 中的 AppModule /future/dar-wepapp/src/app/app.module.ts 和 /media/vimal/personal/future/dar-wepapp/src/app/login/login.module.ts 中的 loginModule! 请考虑将 /media/vimal/personal/future/dar-wepapp/src/app/properties-view/properties-view.component.ts 中的 PropertiesViewComponent 移动到更高的模块,该模块在 /media/vimal/personal/future/ 中导入 AppModule /media/vimal/personal/future/dar-wepapp/src/app/login/login.module.ts 中的 dar-wepapp/src/app/app.module.ts 和 loginModule。 您还可以创建一个新的 NgModule,在 /media/vimal/personal/future/dar-wepapp/src/app/properties-view/properties-view.component.ts 中导出并包含 PropertiesViewComponent,然后在 /media 中的 AppModule 中导入该 NgModule /vimal/personal/future/dar-wepapp/src/app/app.module.ts 和 /media/vimal/personal/future/dar-wepapp/src/app/login/login.module.ts 中的 loginModule。
./src/main.ts 中的错误
找不到模块:错误:无法解析“/media/vimal/personal/future/dar-wepapp/src”中的“./$$_gendir/app/app.module.ngfactory”
@ ./src/main.ts 3:0-74
@多 ./src/main.ts
绝妙的主意
@BorntraegerMarc @mildfuzz我不知道纱线分辨率有什么问题,但我可以自己尝试一下。 你能给我提供一个我可以修改的package.json
吗?
@ryzy我试过你的 package.json,这就是我得到的:
kamik<strong i="11">@T460p</strong> MINGW64 D:/sandbox/tmp
$ yarn --version
0.24.6
kamik<strong i="12">@T460p</strong> MINGW64 D:/sandbox/tmp
$ yarn
yarn install v0.24.6
info No lockfile found.
[1/4] Resolving packages...
[2/4] Fetching packages...
warning [email protected]: The platform "win32" is incompatible with this module.
info "[email protected]" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
success Saved lockfile.
Done in 81.84s.
kamik<strong i="13">@T460p</strong> MINGW64 D:/sandbox/tmp
$ yarn list enhanced-resolve
yarn list v0.24.6
└─ [email protected]
Done in 0.86s.
kamik<strong i="14">@T460p</strong> MINGW64 D:/sandbox/tmp
$ yarn why enhanced-resolve
yarn why v0.24.6
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Reasons this module exists
- "@angular/cli#@ngtools/webpack" depends on it
- "@angular/cli#
所以 atm 在我看来v0.27.5
不能正确解析依赖关系,而v0.24.6
可以。
@filipesilva谢谢回复。 我正在运行 yarn v0.27.5
所以也许这就是问题所在......
这是我的 package.json:
{
"name": "x",
"version": "1.0.0",
"engine": {
"node": "0.10.x",
"npm": "2.1.x"
},
"homepage": "komed-health.com",
"scripts": {
"build:prod": "ng build --prod"
},
"dependencies": {
"@angular/animations": "4.3.1",
"@angular/common": "4.3.1",
"@angular/compiler": "4.3.1",
"@angular/core": "4.3.1",
"@angular/forms": "4.3.1",
"@angular/http": "4.3.1",
"@angular/platform-browser": "4.3.1",
"@angular/platform-browser-dynamic": "4.3.1",
"@angular/platform-server": "4.3.1",
"@angular/router": "4.3.1",
"@angular/service-worker": "1.0.0-beta.16",
"@codebakery/origami": "1.2.3",
"@types/socket.io-client": "1.4.29",
"angular-translator": "2.2.0",
"check-browser": "0.1.7",
"classlist.js": "1.1.20150312",
"core-js": "2.4.1",
"intl": "1.2.5",
"ngx-auto-unsubscribe": "1.0.0",
"rollup": "0.45.2",
"rollup-plugin-commonjs": "8.0.2",
"rollup-plugin-node-resolve": "3.0.0",
"rxjs": "5.4.2",
"tributejs": "2.3.7",
"zone.js": "0.8.14"
},
"devDependencies": {
"@angular/cli": "1.2.4",
"@angular/compiler-cli": "4.3.1",
"@types/jasmine": "2.5.53",
"browserstack-local": "1.3.0",
"codelyzer": "3.1.2",
"cpr": "2.2.0",
"db-migrate": "0.10.0-beta.21",
"db-migrate-mongodb": "1.2.2",
"enhanced-resolve": "3.3.0",
"jasmine-core": "2.6.4",
"jasmine-spec-reporter": "4.1.1",
"karma": "1.7.0",
"karma-chrome-launcher": "2.2.0",
"karma-cli": "1.0.1",
"karma-coverage-istanbul-reporter": "1.3.0",
"karma-jasmine": "1.1.0",
"karma-jasmine-html-reporter": "0.2.2",
"polymer-cli": "1.3.1",
"protractor": "5.1.2",
"rimraf": "2.6.1",
"ts-node": "3.2.1",
"tslint": "5.5.0",
"typescript": "2.4.2"
}
}
@BorntraegerMarc可能尝试在dependencies
以及devDependencies
下显式指定"enhanced-resolve": "3.3.0"
devDependencies
@bmcswee也没有用...
@filipesilva
根据您对问题 #7125 的评论,我正在使用最新的 cli。
- 使用最新的 rc1
- 安装了[email protected]还是同样的错误。
使用yarn
它不起作用,使用npm
它起作用。
yarn why v0.27.5
[1/4] Why do we have the module "enhanced-resolve"...?
[2/4] Initialising dependency graph...
[3/4] Finding dependency...
[4/4] Calculating file sizes...
info Has been hoisted to "enhanced-resolve"
info This module exists because it's specified in "devDependencies".
Done in 0.82s.
yarn list v0.27.5
├─ [email protected]
└─ [email protected]
└─ [email protected]
Done in 0.78s.
md5-5f5afc9e77bd4c2f2ec312c6146b7f7e
ng new my-prj --skip-install --skip-git -dir my-prj --style scss --routing
除了添加[email protected]
之外,项目中没有进行其他更改
@filipesilva确实,这似乎是一些纱线问题! 我将其升级到下一个版本(0.28.4),但错误仍然存在。
现在,我将 yarn 降级为v0.24.6
,与您的相同,模块分辨率似乎没问题([email protected])但错误仍然存在。
$ node -v
v6.11.0
$ yarn list
yarn list v0.24.6
...
├─ @angular/[email protected]
...
├─ @ngtools/[email protected]
│ ├─ [email protected]
...
├─ [email protected]
...
├─ [email protected]
│ ├─ enhanced-resolve@^3.3.0
...
$ yarn why enhanced-resolve
yarn why v0.24.6
info Reasons this module exists
- "@angular/cli#@ngtools/webpack" depends on it
- "@angular/cli#webpack" depends on it
与以前相同的package.json 。
全新安装没有 node_modules 和 yarn.lock 并清除纱线缓存。
AoT 构建错误仍然存在(请参阅完整转储)。 奇怪的...
@filipesilva您是否尝试过实际构建它(使用 AoT),是否有效? (因为你没有明确提到构建,只是关于模块分辨率)。
有人可以重新打开这张票,还是我们应该为纱线创建一张新的票?
Yarn 将继续为需要它的包安装 3.4 版本(例如 webpack 在版本号中使用 ^)。 我设法修复它的唯一方法是通过手动更改增强解析 ^3.4.0 条目的版本和解析字段以指向 3.3.0 来修改我的 yarn.lock。
@kavi87是的,这也对我
@BorntraegerMarc 难道长期解决方案不是在等待增强型解决方案自行修复吗?
@stwic似乎他们已经发布了“修复程序”。 但我不确定这是否真的解决了它或者是原因......
@BorntraegerMarc https://github.com/webpack/enhanced-resolve/issues/98#issuecomment -317516344
非常感谢@cebor所以看起来我们需要等待@ngtools/webpack
方面的长期修复。 enhanced-resolve
库行为正确。 你们什么时候期望在@ngtools/webpack
正确实现WebpackCompilerHost
@ngtools/webpack
? 也许专注于实际修复然后尝试让纱线在当前设置下运行更有意义。 我很确定如果我们使用WebpackCompilerHost
修复程序获得最新的 angular-cli 版本,yarn 会再次工作
@filipesilva :你能看看我之前的评论, https: //github.com/angular/angular-cli/issues/7113#issuecomment -317599036,让我知道它是否与这个问题有关? 如果没有,我将用最少的重现打开一个新问题。
@samridh90我不认为这是相关的。 我的浏览器毫无问题地执行了我的 prod 构建...
@BorntraegerMarc :您的应用程序是否有任何延迟加载的路由?
@samridh90是的
如果npm install [email protected]
不起作用并且您正在使用 webpack,您可能也想尝试npm install [email protected]
。 今天失去了 3 个小时 :(
@filipesilva你有时间https://github.com/yarnpkg/yarn/issues/4024
@filipesilva我有同样的问题,我使用了@ngtools/webpack
,所有包更新到最新,见下文:
"@angular/compiler-cli": "^4.3.1",
"@angular/platform-server": "^4.3.1",
"@ngtools/webpack": "^1.5.3",
"webpack": "^3.4.0",
"@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.1",
"@angular/core": "^4.3.1",
"@angular/forms": "^4.3.1",
"@angular/http": "^4.3.1",
"@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.1",
"@angular/router": "^4.3.1",
是的, @ngtools/webpack
和[email protected]
也可以使用 npm 破坏构建。
我们不应该重新打开这个问题吗? 似乎,对于许多场景,这绝对不是固定的。
将我算作那些无法与[email protected]
。 感谢@jpduckwo牺牲了他的 3 个小时来拯救我的; 降级到[email protected]
效果很好。
我使用纱线安装的快速修复:在我的 package.json 中将 Enhanced-resolve 固定到“3.3.0”并添加了一个“postinstall”脚本,它删除了 webpack 中的 Enhanced-resolve
目前, npm install [email protected] [email protected]将解决这些问题。 Txanks
如果您使用纱线, @play2web不会得到解决...
因此,目前官方(100% 工作)的解决方法是将 yarn 降级到 0.24.6 版
@BorntraegerMarc你能提供一个参考,说明这是“官方”的解决方法吗? AFAIK 没有修复,因为@ngtools/webpack
和webpack
之间存在依赖冲突。 @ngtools/webpack
可能需要更新才能为纱线用户解决此问题。
好的@uitgewis与“官方”我的意思是它被正式承认(直到现在)作为一个错误: https :
如果 sokra 检测到的问题(https://github.com/webpack/enhanced-resolve/issues/98#issuecomment-317516344)在下一版本的路线图上,那么“官方”声明会很棒。 或者该怎么做才能解决这个问题?
现状:
@ngtools/webpack
不能单独使用 webpack > 3.3.0
@angular/cli
不适用于纱线 > 0.24.6
尽管我讨厌这种解决方法,但如果降级yarn
不适合您,您可以在技术上手动“修复” yarn.lock
文件。 升级与 Angular 相关的依赖项后,您的锁文件应该是这样的:
[email protected]:
version "3.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3"
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.4.0"
object-assign "^4.0.1"
tapable "^0.2.5"
enhanced-resolve@^3.0.0:
version "3.4.1"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.4.1.tgz#0421e339fd71419b3da13d129b3979040230476e"
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.4.0"
object-assign "^4.0.1"
tapable "^0.2.7"
替换为:
[email protected], enhanced-resolve@^3.0.0:
version "3.3.0"
resolved "https://registry.yarnpkg.com/enhanced-resolve/-/enhanced-resolve-3.3.0.tgz#950964ecc7f0332a42321b673b38dc8ff15535b3"
dependencies:
graceful-fs "^4.1.2"
memory-fs "^0.4.0"
object-assign "^4.0.1"
tapable "^0.2.5"
您将能够再次使用 0.27.5 进行构建。 请注意,正如文件本身告诉您的那样,不应手动编辑yarn.lock
文件,但在找到更强大的修复程序之前,此操作_应该_起作用。
@Gustorn对我不起作用,每次我运行yarn
它都会再次将错误的条目添加到yarn.lock
。
这是我的构建失败的仓库: https :
@cebor ,我应该提到,这种解决方法仅适用于普通的 CLI 项目(或者换句话说:它解决了yarn
问题,但 _does not_ 解决了webpack
问题)。
由于您将webpack@^3.4.1
作为依赖项,您无法修复锁文件,因为新版本明确依赖于enhanced-resolve@^3.4.0
。 您只能通过先降级到[email protected]
来解决此问题。
@cebor在按照@Gustorn 的建议进行操作后,运行yarn --pure-lockfile
应该可以。 可能还想确保删除您的node_modules
。
找不到模块:错误:无法解析“hello/src”中的“./$$_gendir/app/app.module.ngfactory”
就像对收到错误的人的附加说明一样。 它也可能是您的代码的问题。 请在此处查看会破坏 AOT 的检查事项。 有些事情会破坏构建,有些事情会在运行时失败(根据经验)
https://github.com/rangle/angular-2-aot-sandbox
昨天我受到了特别的打击,因为我遇到了这个错误并且在我的应用程序中遇到了这些问题之一😂
@krjordan我不会在这里重复,但如果你按照我在 #7136 中描述的那样进行编辑,你_不应该_需要--pure-lockfile
选项。
Yarn 用户: https: //github.com/angular/angular-cli/issues/7136#issuecomment -318313404 中有专门的讨论话题。
一切为了用户:你不应该有webpack
您的package.json。 同时安装多个版本时,Webpack 无法正常工作。 有关更多信息,请参阅https://github.com/angular/angular-cli/issues/6417#issuecomment -315708400。
我们将更新@ngtools/webpack
(根据 https://github.com/webpack/enhanced-resolve/issues/98#issuecomment-317518593)但这不是短期内会发生的事情,因为它需要相当多的工作。
同时,我们固定了[email protected]
(https://github.com/angular/angular-cli/pull/7123) 和[email protected]
(https://github.com/angular/angular- cli/pull/71300)。 这些导致正确解决依赖关系。
@samridh90不知道您的https://github.com/angular/angular-cli/issues/7113#issuecomment -317599036 中发生了什么,但似乎无关。 请问你能开一个新问题吗?
@filipesilva所以为了与 angular-cli 项目一起使用,在我们的 package.json 中添加[email protected]
是否足够,或者我们也应该绑定到[email protected]?
根据上面其他人的评论,它似乎已在@angular/ [email protected] 中修复,但是我们现在无法升级到那个。
什么是中间修复,上面提到的第一件事是否足够好?
仅供参考,我仍然在刚刚发布的1.2.6
上遇到此错误,尽管有传言说它会起作用,但增强分辨率提高到 3.4.1 。
我看到一个建议,这可能与 npm 5 ......不知何故? (我确实在更新之前删除了我的package-lock.json
。)
👉 编辑:请参阅下面的评论,它实际上是无关的。
对于 cli 项目
0.24.6
3.3.0
对于使用@ngtools/webpack
非 cli 项目
0.24.6
3.3.0
3.3.0
我们在昨天 (https://github.com/angular/angular-cli/pull/7169) 得到了一个新的修复,在1.2.6
/ 1.3.0-rc.3
。 我们希望它能让[email protected]
及以下的代码即使在纱线下也能正确解析。
@russelltrafford很难说,这取决于您的包管理器。 如果你在 npm 上,那应该没问题。 为了测试,删除package-lock.json
/ yarn.lock
/ node_modules
,用[email protected]
, npm install
, ng build --aot
更新package.json
ng build --aot
。 如果您收到有关$$gendir
的错误,则它不起作用。 如果你不这样做,它的工作。
@michaelsanford你用的是 npm 还是 yarn? 你能提供我你的 package.json 吗? 我可以自己测试一下,看看发生了什么。
此外,当使用1.2.6
/ 1.3.0-rc.3
您不需要在enhanced-resolve
包含webpack
package.json
。 在您的package.json
包含webpack
package.json
(https://github.com/angular/angular-cli/issues/7113#issuecomment-318328125)甚至可能会破坏内容。
@ngtools/[email protected]
再次正常工作👍
@filipesilva 很高兴这已解决,但作为一个相关问题,是否可以修复无意义的错误消息,以便将来类似的错误提供任何有用的信息? (涉及开发人员看不到的文件的错误不是那么用户友好)。
使用@ngtools/[email protected]
并没有解决我的问题。 我必须在运行npm install
[email protected]
后手动安装node_modules/enhanced-resolve
复制/粘贴到node_modules/webpack/node_modules/enhanced-resolve
才能正常工作。
@filipesilva但是当然! 谢谢😄
我在 Windows 10 上运行[email protected]和[email protected] (在 cmdr shell 下)。
我的全局 Angular CLI 是 1.2.6,与我的项目中安装的相匹配:
λ npm ls -g @angular/cli
`-- @angular/[email protected]
这是我的项目的package.json
:
{
"name": "prod-test-fail",
"version": "1.0.0",
"private": true,
"dependencies": {
"@angular/animations": "^4.3.1",
"@angular/common": "^4.3.1",
"@angular/compiler": "^4.3.1",
"@angular/core": "^4.3.1",
"@angular/forms": "^4.3.1",
"@angular/http": "^4.3.1",
"@angular/platform-browser": "^4.3.1",
"@angular/platform-browser-dynamic": "^4.3.1",
"@angular/router": "^4.3.1",
"bootstrap": "^3.3.7",
"core-js": "^2.4.1",
"font-awesome": "^4.7.0",
"jquery": "^3.2.1",
"moment": "^2.18.1",
"rxjs": "^5.4.2",
"zone.js": "^0.8.14"
},
"devDependencies": {
"@angular/cli": "1.2.6",
"@angular/compiler-cli": "^4.3.1",
"@angular/language-service": "^4.3.1",
"@types/core-js": "^0.9.42",
"@types/jquery": "^3.2.9",
"@types/node": "8.0.17",
"codelyzer": "^3.1.2",
"ts-node": "~3.3.0",
"tslint": "^5.5.0",
"typescript": "^2.4.2"
}
}
今天早上,我删除了node_modules/
文件夹, package-lock.json
和 npm 安装了上述包,结果如下:
ng build
:
λ ng build
Hash: 02193d0724fa51e87a0d
Time: 24523ms
chunk {0} main.bundle.js, main.bundle.js.map (main) 2.24 MB {2} [initial] [rendered]
chunk {1} polyfills.bundle.js, polyfills.bundle.js.map (polyfills) 174 kB {3} [initial] [rendered]
chunk {2} vendor.bundle.js, vendor.bundle.js.map (vendor) 3.89 MB [initial] [rendered]
chunk {3} inline.bundle.js, inline.bundle.js.map (inline) 0 bytes [entry] [rendered]
ng build --prod
和ng build --aot
:
λ ng build --prod
Hash: adc8c0af1f195a4cd49a
Time: 6075ms
chunk {0} polyfills.dd983c51be469b02aa15.bundle.js (polyfills) 174 kB {3} [initial] [rendered]
chunk {1} main.10609bd5e9ef4fd0b393.bundle.js (main) 713 bytes {2} [initial] [rendered]
chunk {2} vendor.a590f07d547ec4b39908.bundle.js (vendor) 849 kB [initial] [rendered]
chunk {3} inline.bf6c517a9f6f64c103ca.bundle.js (inline) 0 bytes [entry] [rendered]
ERROR in Cannot determine the module for class ModalInstanceComponent in C:/Users/<me>/app/src/ui/src/app/components/modal/modalInstance.ts! Add ModalInstanceComponent to the NgModule to fix it.
ERROR in ./src/main.ts
Module not found: Error: Can't resolve './../$$_gendir/src/app.module.ngfactory' in 'C:\Users\<me>\app\src\ui\src'
@ ./src/main.ts 3:0-77
@ multi ./src/main.ts
值得注意的是(这应该是我问题的真正根源)这是一个诞生于 _beta-6_ 的 angular 2 项目,随着 angular 的更新,我们每 3 周逐步更新一次。
我对该项目进行了相当广泛的更改,以允许它使用ng
进行编译。 我遵循或多或少接受的指南,使用ng new
创建模板项目并手动复制文件和库更改。
这解释了悬而未决的ModalInstanceComponent
错误:它没有模板并在另一个组件中实例化。 如果我将它包含在我的主要@NgModule
,它会引发一连串的新错误,所以我暂时保持原样。 我想这是(现在?)一种反模式,并将重新审视它。
这种类型的问题几乎同时出现,但可能无关。 我现在似乎没有遇到这个错误0.8.17
,但它可能首先遇到can't resolve $$_gendir
错误。 我已经尝试过.17
和.16
。
(对于那些可能会畏缩的人,是的,我正在删除 jQuery 😉。)
@michaelsanford啊,我现在明白了:你得到的第一个错误实际上是导致第二个错误:
无法确定 C:/Users/ 中类 ModalInstanceComponent 的模块中的错误
/app/src/ui/src/app/components/modal/modalInstance.ts! 将 ModalInstanceComponent 添加到 NgModule 以修复它。
由于那失败了,AOT 并没有真正编译任何东西,所以你会得到第二个错误:
找不到模块:错误:无法解析“./../$$_gendir/src/app.module.ngfactory”
这是真的(但很难解释)。
您必须修复第一个错误才能正确处理第二个错误。
@filipesilva我强烈怀疑可能是这种情况; 非常感谢您调查并确认,在使用ng
之前我们没有尝试过 AOT。
我怀疑我们仍然有很多 AOT 不兼容的代码。 我有一个重构任务将这个无模板的@Component
到一个@Directive
(我什
_Update_ 对于仍然需要 _prod_ 包并且刚开始使用ng
其他有类似问题的人,以下发出一个功能性应用程序包:
ng build --prod --aot=false
好找到@filipesilva !
那么这是否只影响使用模态的项目? 我们刚刚添加了我们的第一个模态,所以这就是我们“突然”遇到这个问题的原因吗? 话虽如此,我们的另一个应用程序不使用模态,并且也会出现此错误...
@russelltrafford本身不是模态,而是不在任何 NgModule 中的整体组件。
[email protected]对我不起作用
在 package.json "enhanced-resolve": "3.3.0" 中包含这一行
运行 npm install 和 ng build --prod
谢谢
大家好,我删除了一个未使用的组件,它可以工作。
希望angular团队重视这个错误,太难定位了。
当我运行 ng build --prod 时,它是否抱怨私有表单变量,对此有任何解决方案,还是我真的必须将所有内容都设为公开?
您应该将所有从模板访问的成员设为公开,而不是私有。 我认为它会解决你的问题@ThalesMatoso
酷......这会起作用,但如果你谈论一个更大的系统,你能不能挡路? 真的是唯一的选择吗?
@ThalesMatoso当您在其模板中引用组件类的字段时,您实际上是在为 Angular 的渲染引擎编写指令以获取这些值并将它们显示在 DOM 上。 由于渲染器是独立于组件类的外部,因此尝试访问私有变量将导致 TypeScript 编译错误。 因此,组件类中可能被外部服务触及的任何字段(例如模板中引用的字段或使用@ViewChild
等装饰器注释的字段)都必须是公共的。
另外,需要明确的是,这是一个 Angular 特性/要求。 不特定于 CLI。
我认为npm i [email protected]
不是可靠的修复方法是否正确? @angular/[email protected]
取决于[email protected]
而后者又取决于[email protected]
。 npm 似乎相当有决心确保 webpack 得到它所要求的。
我试过安装[email protected]
并且它工作了一次,但后来我再次运行npm install
并且它停止工作。 我是不是遗漏了什么,还是很难以稳定的方式解决这个问题?
@studds您不需要使用较新的版本手动添加enhanced-resolve
。
安装“enhanced-resolve”:“^3.3.0”为我解决了
我增强了解析 3.3.0 和 ngtools webpack 1.6.2,
仍然看到错误
字段“浏览器”不包含有效的别名配置
使用描述文件后:/Users/ui/package.json(相对路径:./src/app/Components/selector)
"@angular/animations": "^4.3.6",
"@angular/cdk": "2.0.0-beta.8",
"@angular/common": "^4.3.6",
"@angular/compiler": "^4.3.6",
"@angular/compiler-cli": "^4.3.6",
"@angular/core": "^4.3.6",
"@angular/forms": "^4.3.6",
"@angular/http": "^4.3.6",
"@angular/material": "^2.0.0-beta.8",
"@angular/platform-browser": "^4.3.6",
"@ngrx/core": "^1.0.2",
"@ngrx/effects": "^2.0.0",
"@ngrx/store": "^2.1.2",
"@ngtools/webpack": "^1.6.2",
"enhanced-resolve": "^3.3.0",
最后使它与 devDependencies "@angular/cli": "1.2.6" 和依赖项 "enhanced-resolve": "3.3.0" 和 @angular/*:"^4.3.6" 一起工作
创建新的 angular 项目时出现此错误。
通过 npm 安装工具包。
npm 错误! Windows_NT 10.0.10240
npm 错误! argv "C:\Program Files\nodejs\node.exe" "C:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" "--quiet" "安装"
npm 错误! 节点 v6.10.0
npm 错误! npm v3.10.10
npm 错误! C:\Users\Sukeshu\AppData\Local\Tempnpm-3120-1165392c\registry.npmjs.org\jasmine-spec-reporter-\jasmine-spec-reporter-4.1.1.tgz shasum 检查失败
npm 错误! 预期:5a6d58ab5d61bea7309fbc279239511756b1b588
npm 错误! 实际:1cca12519560608e42bb4efd78f30d818740a4f9
npm 错误! 来自: https :
npm 错误!
npm 错误! 如果您需要帮助,您可以在以下位置报告此错误:
npm 错误! https://github.com/npm/npm/issues
npm 错误! 请在任何支持请求中包含以下文件:
npm 错误! C:\Users\Sukeshu\Desktopng2\dappnpm-debug.log
软件包安装失败,请参见上文。
软件包安装失败,请参见上文。
"enhanced-resolve": "3.3.0" 为我解决了这个问题。
只是说...如果你使用 prod build 你应该使用shrinkwrap...它可供你们使用。 还有,毛线。
这个问题对我来说使用 ngtools/webpack 进行我的角度构建......没有使用 angular-cli,我专门使用了 ngtools/webpack 1.5.3 并且问题自行解决......使用其他插件......
因此,对于使用 ngtools/webpack 的人来说,此时只需使用 1.5.3 版……无论您使用什么版本,添加另一个包都无济于事。
将 angular/cli 升级到 1.2.4 为我解决了这个问题。
使用旧 cli 创建的 Angular 应用程序仍然不起作用。 为了解决这个问题,我只是从一个新的应用程序中复制了一个新的 package.json。
如果你想让现有的 angular 应用程序运行,(其中的一些包)以下包(我在运行我自己的应用程序时得到的差异)应该升级:
diff seodemo/package.json aotdemo/package.json
2c2
< "name": "seodemo",
---
> "name": "aotdemo",
15,23c15,23
< "@angular/animations": "^4.0.0",
< "@angular/common": "^4.0.0",
< "@angular/compiler": "^4.0.0",
< "@angular/core": "^4.0.0",
< "@angular/forms": "^4.0.0",
< "@angular/http": "^4.0.0",
< "@angular/platform-browser": "^4.0.0",
< "@angular/platform-browser-dynamic": "^4.0.0",
< "@angular/router": "^4.4.3",
---
> "@angular/animations": "^4.2.4",
> "@angular/common": "^4.2.4",
> "@angular/compiler": "^4.2.4",
> "@angular/core": "^4.2.4",
> "@angular/forms": "^4.2.4",
> "@angular/http": "^4.2.4",
> "@angular/platform-browser": "^4.2.4",
> "@angular/platform-browser-dynamic": "^4.2.4",
> "@angular/router": "^4.2.4",
25,26c25,26
< "rxjs": "^5.1.0",
< "zone.js": "^0.8.4"
---
> "rxjs": "^5.4.2",
> "zone.js": "^0.8.14"
29,31c29,31
< "@angular/cli": "1.2.0",
< "@angular/compiler-cli": "^4.0.0",
< "@angular/language-service": "^4.0.0",
---
> "@angular/cli": "1.4.3",
> "@angular/compiler-cli": "^4.2.4",
> "@angular/language-service": "^4.2.4",
35c35
< "codelyzer": "~3.0.1",
---
> "codelyzer": "~3.1.1",
45c45
< "ts-node": "~3.0.4",
---
> "ts-node": "~3.2.0",
如果这对其他人有帮助:
在阅读了整件事之后,我注意到了依赖关系: "@angular/cli": "1.1.x",
当我允许它升级时,问题就消失了。
我在 Angular CLI 1.5.0 中遇到了同样的问题 我也有 Enhanced resolve 3.3.0
我也是。 仍然得到:错误:无法解析'./$$_gendir/app/app.module.ngfactory'
即使在使用 Angular CLI 1.5.0 和 Enhanced resolve 3.3.0 之后
同样在这里。 任何更新 ?
[email protected]对我不起作用
包.json
{
"name": "LENDZ",
“版本”:“0.0.1”,
"author": "离子框架",
"主页": " http://ionicframework.com/ ",
“私人”:真的,
“脚本”:{
"clean": "ionic-app-scripts clean",
"build": "ionic-app-scripts build",
"lint": "ionic-app-scripts lint",
" ionic:build ": "ionic-app-scripts build",
" ionic:serve ": "ionic-app-scripts serve"
},
“依赖关系”:{
"@angular/common": "5.0.0",
"@angular/compiler": "5.0.0",
"@angular/compiler-cli": "5.0.0",
"@angular/core": "5.0.0",
"@angular/forms": "5.0.0",
"@angular/http": "5.0.0",
"@angular/platform-browser": "5.0.0",
"@angular/platform-browser-dynamic": "5.0.0",
"@ionic-native/camera": "^4.4.2",
"@ionic-native/core": "4.3.2",
"@ionic-native/diagnostic": "^4.5.2",
"@ionic-native/facebook": "^4.4.2",
"@ionic-native/file": "^4.4.2",
"@ionic-native/file-path": "^4.4.2",
"@ionic-native/geolocation": "^4.4.2",
"@ionic-native/google-maps": "^4.4.2",
"@ionic-native/http": "^4.4.2",
"@ionic-native/native-storage": "^4.4.2",
"@ionic-native/network": "^4.5.2",
"@ionic-native/onesignal": "^4.5.2",
"@ionic-native/push": "^4.4.2",
"@ionic-native/splash-screen": "4.3.2",
"@ionic-native/status-bar": "4.3.2",
"@ionic-native/stripe": "^4.5.2",
"@ionic-native/transfer": "^3.14.0",
"@ionic/storage": "^2.1.3",
"angular2-moment": "^1.7.0",
"cordova-android": "6.3.0",
"cordova-browser": "~5.0.1",
"cordova-plugin-camera": "^3.0.0",
"cordova-plugin-device": "^1.1.4",
"cordova-plugin-facebook4": "^1.9.1",
"cordova-plugin-file": "^5.0.0",
"cordova-plugin-file-transfer": "^1.7.0",
"cordova-plugin-filepath": "^1.1.0",
"cordova-plugin-geolocation": "^3.0.0",
"cordova-plugin-googlemaps": "^2.1.1",
"cordova-plugin-inappbrowser": "~1.7.2",
"cordova-plugin-ionic-webview": "^1.1.11",
"cordova-plugin-nativestorage": "^2.2.2",
"cordova-plugin-network-information": "^1.3.4",
"cordova-plugin-splashscreen": "^4.0.3",
"cordova-plugin-stripe": "^1.5.3",
"cordova-plugin-whitelist": "^1.3.1",
"cordova-sqlite-storage": "^2.1.2",
"cordova.plugins.diagnostic": "^3.7.2",
"enhanced-resolve": "^3.4.1",
“离子角”:“3.9.2”,
"ionic-plugin-keyboard": "^2.2.1",
"ionic2-rating": "^1.2.2",
"ionicons": "3.0.0",
"onesignal-cordova-plugin": "^2.2.4",
"rxjs": "5.5.2",
"sw-工具箱": "3.6.0",
“zone.js”:“0.8.18”
},
“开发依赖”:{
"@ionic/app-scripts": "^3.1.7",
“打字稿”:“2.4.2”
},
"description": "一个 Ionic 项目",
“科尔多瓦”:{
“插件”:{
"cordova-plugin-device": {},
"cordova-plugin-ionic-webview": {},
"cordova-plugin-splashscreen": {},
"cordova-plugin-whitelist": {},
“离子插件键盘”:{},
“cordova-plugin-facebook4”:{
"APP_ID": "xxxxxxxxxxx",
"APP_NAME": "LENDZ"
},
“cordova-plugin-nativestorage”:{},
“cordova-sqlite-storage”:{},
"cordova-plugin-camera": {},
"cordova-plugin-file": {},
"cordova-plugin-file-transfer": {},
"cordova-plugin-filepath": {},
“cordova-plugin-googlemaps”:{
"API_KEY_FOR_ANDROID": "xxxxxxxxxxxxxxxxxxxxxxxx",
"API_KEY_FOR_IOS": "xxxxxxxxxxxxxxxxxxxx"
},
"cordova-plugin-geolocation": {},
"onesignal-cordova-plugin": {},
"cordova.plugins.diagnostic": {},
"cordova-plugin-network-information": {},
"cordova-plugin-inappbrowser": {},
“cordova-plugin-stripe”:{}
},
“平台”:[
"浏览器",
“安卓”
]
}
}
请帮忙
正如@cbeaujoin所说的那样。 如果您保持这种状态,您将可以毫无困难地使用 AOT 进行构建。
@angular/*:"^4.3.6"
"enhanced-resolve": "3.3.0"
devDependencies
"@angular/cli": "1.2.6"
"typescript": "^2.3.4"
我必须补充一点,打字稿对我来说必须是 2.3.4,最重要的是,构建时间大幅减少到 6:35 左右,而之前大约需要 29 分钟来构建。 我会保持这种状态一段时间。
最有用的评论
我注意到了同样的问题,在
npm i [email protected]
我可以用 AOT 构建