Angular7 - 生产构建在通过 Bitbucket 包时失败
Angular7 - Production build fails while going through Bitbucket package
我想构建一个系统,其中 angular 组件可以使用 bitBucket 在多个应用程序中重复使用。
目前我有以下内容:
- BitBucket Repo A - 存储节点模块。目前模块被创建为一个库,主应用程序被用作演示。当从这个 repo 请求模块时,库被构建和导出。
(https://bitbucket.org/joseph118/ng-module-x/src/master/)
- BitBucket Repo B - 使用 "BitBucket Repo A"(安装库)和更多(Web 应用程序)的应用程序。 (https://bitbucket.org/joseph118/app-x/src/master/)
在 Repo A 上,应用程序能够构建、生产构建、构建库并提供服务。
在 Repo B 上,应用程序能够构建和服务,但在生产构建时失败。这将最终抛出 'module not found' 但检查 node_modules 文件夹,我可以验证一切似乎都是有序的。
在这种情况下,我执行了以下命令:'ng build --prod --verbose' 以从进程中获取更多信息。但是我得到了以下结果:
ERROR in ./node_modules/ng-module-x/dist/lib-module/lib-module.ngfactory.js
Module not found: Error: Can't resolve 'lib-module' in 'C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module'
resolve 'lib-module' in 'C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module'
Parsed request is a module
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in C:/Users/joseph.borg/Documents/P Repo/app-x/
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: ./lib-module)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.js doesn't exist
as directory
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module doesn't exist
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\node_modules doesn't exist or is not a directory
C:\Users\node_modules doesn't exist or is not a directory
C:\node_modules doesn't exist or is not a directory
looking for modules in C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: ./node_modules/lib-module)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.js doesn't exist
as directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module doesn't exist
我已尝试对项目进行多次调整,但对构建仍然无济于事。
复制步骤:克隆回购 B (https://bitbucket.org/joseph118/app-x/src/master/) 和 运行 'ng build --prod'.
如果我有什么可以提供或解释的,请告诉我。
更新了应用程序 tsconfig.json 并添加了以下配置:
"paths": {
"data-table": [
"./node_modules/ng-module-x/dist/lib-module"
],
"data-table/*": [
"./node_modules/ng-module-x/dist/lib-module/*"
]
}
然后更新导入以指向解决问题的 'data-table'。
import { LibModuleModule } from 'lib-module';
我想构建一个系统,其中 angular 组件可以使用 bitBucket 在多个应用程序中重复使用。
目前我有以下内容:
- BitBucket Repo A - 存储节点模块。目前模块被创建为一个库,主应用程序被用作演示。当从这个 repo 请求模块时,库被构建和导出。 (https://bitbucket.org/joseph118/ng-module-x/src/master/)
- BitBucket Repo B - 使用 "BitBucket Repo A"(安装库)和更多(Web 应用程序)的应用程序。 (https://bitbucket.org/joseph118/app-x/src/master/)
在 Repo A 上,应用程序能够构建、生产构建、构建库并提供服务。
在 Repo B 上,应用程序能够构建和服务,但在生产构建时失败。这将最终抛出 'module not found' 但检查 node_modules 文件夹,我可以验证一切似乎都是有序的。
在这种情况下,我执行了以下命令:'ng build --prod --verbose' 以从进程中获取更多信息。但是我得到了以下结果:
ERROR in ./node_modules/ng-module-x/dist/lib-module/lib-module.ngfactory.js
Module not found: Error: Can't resolve 'lib-module' in 'C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module'
resolve 'lib-module' in 'C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module'
Parsed request is a module
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
resolve as module
looking for modules in C:/Users/joseph.borg/Documents/P Repo/app-x/
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: .)
Field 'browser' doesn't contain a valid alias configuration
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: ./lib-module)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module.js doesn't exist
as directory
C:\Users\joseph.borg\Documents\P Repo\app-x\lib-module doesn't exist
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\lib-module\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\dist\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\ng-module-x\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\P Repo\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\Documents\node_modules doesn't exist or is not a directory
C:\Users\joseph.borg\node_modules doesn't exist or is not a directory
C:\Users\node_modules doesn't exist or is not a directory
C:\node_modules doesn't exist or is not a directory
looking for modules in C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: ./node_modules)
Field 'browser' doesn't contain a valid alias configuration
using description file: C:\Users\joseph.borg\Documents\P Repo\app-x\package.json (relative path: ./node_modules/lib-module)
no extension
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module doesn't exist
.ts
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.ts doesn't exist
.tsx
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.tsx doesn't exist
.mjs
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.mjs doesn't exist
.js
Field 'browser' doesn't contain a valid alias configuration
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module.js doesn't exist
as directory
C:\Users\joseph.borg\Documents\P Repo\app-x\node_modules\lib-module doesn't exist
我已尝试对项目进行多次调整,但对构建仍然无济于事。
复制步骤:克隆回购 B (https://bitbucket.org/joseph118/app-x/src/master/) 和 运行 'ng build --prod'.
如果我有什么可以提供或解释的,请告诉我。
更新了应用程序 tsconfig.json 并添加了以下配置:
"paths": {
"data-table": [
"./node_modules/ng-module-x/dist/lib-module"
],
"data-table/*": [
"./node_modules/ng-module-x/dist/lib-module/*"
]
}
然后更新导入以指向解决问题的 'data-table'。
import { LibModuleModule } from 'lib-module';