无法在 getRequiredModulePath 读取 NodeObject.getText 未定义的 属性 'text'
Cannot read property 'text' of undefined at NodeObject.getText at getRequiredModulePath
生成浏览器应用程序包时出错(阶段:设置)。
什么会导致此错误?
来自控制台的信息:
Generating browser application bundles (phase: setup)...
TypeError: Cannot read property 'text' of undefined
at NodeObject.getText (/opt/app-root/src/node_modules/typescript/lib/typescript.js:152697:31)
at getRequiredModulePath (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/host/umd_host.js:519:99)
at Object.getImportsOfUmdModule (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/host/umd_host.js:510:23)
at UmdDependencyHost.extractImports (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/umd_dependency_host.js:43:54)
at UmdDependencyHost.DependencyHostBase.recursivelyCollectDependencies (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_host.js:85:32)
at UmdDependencyHost.DependencyHostBase.collectDependencies (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_host.js:38:22)
at DependencyResolver.getEntryPointWithDependencies (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_resolver.js:75:22)
at EntryPointCollector.walkDirectoryForPackages (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/entry_point_collector.js:47:52)
at EntryPointCollector.walkDirectoryForPackages (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/entry_point_collector.js:75:103)
at /opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/program_based_entry_point_finder.js:124:100
信息来自 angular-errors.log
An error occurred during the build:
Error: NGCC failed.
at NgccProcessor.process (/opt/app-root/src/node_modules/@ngtools/webpack/src/ngcc_processor.js:139:19)
at /opt/app-root/src/node_modules/@ngtools/webpack/src/ivy/plugin.js:129:27
at Hook.eval [as call] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:19:10), :28:1)
at Hook.CALL_DELEGATE [as _call] (/opt/app-root/src/node_modules/tapable/lib/Hook.js:14:14)
at Compiler.newCompilation (/opt/app-root/src/node_modules/webpack/lib/Compiler.js:1043:30)
at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:1088:29
at Hook.eval [as callAsync] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), :22:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/opt/app-root/src/node_modules/tapable/lib/Hook.js:18:14)
at Compiler.compile (/opt/app-root/src/node_modules/webpack/lib/Compiler.js:1083:28)
at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:508:12
at Compiler.readRecords (/opt/app-root/src/node_modules/webpack/lib/Compiler.js:920:11)
at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:505:11
at Hook.eval [as callAsync] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), :10:1)
at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/opt/app-root/src/node_modules/tapable/lib/Hook.js:18:14)
at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:502:20
at Hook.eval [as callAsync] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), :22:1)
An unhandled exception occurred: NGCC failed.
See "/tmp/ng-IZbyMh/angular-errors.log" for further details.
angular 版本 12.2.12 和 12.2.11 中存在错误,使用 12.2.10 会修复它,或者您可能需要等待他们发布新版本或修复 12.2.12
注意:如果您在 package.json 文件中使用 ^12.0.1,请将其替换为 12.2.10
这似乎是由 12.2.11 中添加的 improved UMD module detection 引起的,将版本固定到 12.2.10 可以避免这个问题,但没有解决根本原因,即依赖项可能需要更新。
对我们来说,包裹是 @auth0/angular-jwt
,但对您来说可能有所不同。为了找到它,我们必须使用 Linux 工具 strace
来找出在构建失败之前打开了哪个文件:
strace -f npm run build 2>&1 | egrep 'open|Error'
(最终)产生了输出
[pid 29550] open(".../node_modules/@auth0/angular-jwt/package.json", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] open(".../node_modules/@auth0/angular-jwt/bundles/core.umd.js", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] open(".../node_modules/@auth0/angular-jwt/bundles/core.umd.js", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] open(".../node_modules/@angular/compiler-cli/bundles/ngcc/__ngcc_lock_file__", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] write(2, "TypeError: Cannot read property "..., 1535TypeError: Cannot read property 'text' of undefined
[pid 29582] open(".../node_modules/@angular/compiler-cli/bundles/ngcc/__ngcc_lock_file__", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 29582] <... open resumed> ) = -1 ENOENT (No such file or directory)
[pid 29393] write(2, "(node:29393) UnhandledPromiseRej"..., 914(node:29393) UnhandledPromiseRejectionWarning: Error: NGCC failed.
错误模块在 运行 之前打开,更新它解决了问题。可能有更简洁的 shell 命令来获取错误,但这对我们来说已经足够了。
- 首先转移到最新的稳定版本
- 删除包-lock.json
- npm 安装
生成浏览器应用程序包时出错(阶段:设置)。 什么会导致此错误?
来自控制台的信息:
Generating browser application bundles (phase: setup)... TypeError: Cannot read property 'text' of undefined at NodeObject.getText (/opt/app-root/src/node_modules/typescript/lib/typescript.js:152697:31) at getRequiredModulePath (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/host/umd_host.js:519:99) at Object.getImportsOfUmdModule (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/host/umd_host.js:510:23) at UmdDependencyHost.extractImports (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/umd_dependency_host.js:43:54) at UmdDependencyHost.DependencyHostBase.recursivelyCollectDependencies (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_host.js:85:32) at UmdDependencyHost.DependencyHostBase.collectDependencies (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_host.js:38:22) at DependencyResolver.getEntryPointWithDependencies (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/dependencies/dependency_resolver.js:75:22) at EntryPointCollector.walkDirectoryForPackages (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/entry_point_collector.js:47:52) at EntryPointCollector.walkDirectoryForPackages (/opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/entry_point_collector.js:75:103) at /opt/app-root/src/node_modules/@angular/compiler-cli/ngcc/src/entry_point_finder/program_based_entry_point_finder.js:124:100
信息来自 angular-errors.log
An error occurred during the build: Error: NGCC failed. at NgccProcessor.process (/opt/app-root/src/node_modules/@ngtools/webpack/src/ngcc_processor.js:139:19) at /opt/app-root/src/node_modules/@ngtools/webpack/src/ivy/plugin.js:129:27 at Hook.eval [as call] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:19:10), :28:1) at Hook.CALL_DELEGATE [as _call] (/opt/app-root/src/node_modules/tapable/lib/Hook.js:14:14) at Compiler.newCompilation (/opt/app-root/src/node_modules/webpack/lib/Compiler.js:1043:30) at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:1088:29 at Hook.eval [as callAsync] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), :22:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/opt/app-root/src/node_modules/tapable/lib/Hook.js:18:14) at Compiler.compile (/opt/app-root/src/node_modules/webpack/lib/Compiler.js:1083:28) at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:508:12 at Compiler.readRecords (/opt/app-root/src/node_modules/webpack/lib/Compiler.js:920:11) at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:505:11 at Hook.eval [as callAsync] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), :10:1) at Hook.CALL_ASYNC_DELEGATE [as _callAsync] (/opt/app-root/src/node_modules/tapable/lib/Hook.js:18:14) at /opt/app-root/src/node_modules/webpack/lib/Compiler.js:502:20 at Hook.eval [as callAsync] (eval at create (/opt/app-root/src/node_modules/tapable/lib/HookCodeFactory.js:33:10), :22:1) An unhandled exception occurred: NGCC failed. See "/tmp/ng-IZbyMh/angular-errors.log" for further details.
angular 版本 12.2.12 和 12.2.11 中存在错误,使用 12.2.10 会修复它,或者您可能需要等待他们发布新版本或修复 12.2.12
注意:如果您在 package.json 文件中使用 ^12.0.1,请将其替换为 12.2.10
这似乎是由 12.2.11 中添加的 improved UMD module detection 引起的,将版本固定到 12.2.10 可以避免这个问题,但没有解决根本原因,即依赖项可能需要更新。
对我们来说,包裹是 @auth0/angular-jwt
,但对您来说可能有所不同。为了找到它,我们必须使用 Linux 工具 strace
来找出在构建失败之前打开了哪个文件:
strace -f npm run build 2>&1 | egrep 'open|Error'
(最终)产生了输出
[pid 29550] open(".../node_modules/@auth0/angular-jwt/package.json", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] open(".../node_modules/@auth0/angular-jwt/bundles/core.umd.js", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] open(".../node_modules/@auth0/angular-jwt/bundles/core.umd.js", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] open(".../node_modules/@angular/compiler-cli/bundles/ngcc/__ngcc_lock_file__", O_RDONLY|O_CLOEXEC) = 19
[pid 29550] write(2, "TypeError: Cannot read property "..., 1535TypeError: Cannot read property 'text' of undefined
[pid 29582] open(".../node_modules/@angular/compiler-cli/bundles/ngcc/__ngcc_lock_file__", O_RDONLY|O_CLOEXEC <unfinished ...>
[pid 29582] <... open resumed> ) = -1 ENOENT (No such file or directory)
[pid 29393] write(2, "(node:29393) UnhandledPromiseRej"..., 914(node:29393) UnhandledPromiseRejectionWarning: Error: NGCC failed.
错误模块在 运行 之前打开,更新它解决了问题。可能有更简洁的 shell 命令来获取错误,但这对我们来说已经足够了。
- 首先转移到最新的稳定版本
- 删除包-lock.json
- npm 安装