Open abhinavek opened 5 days ago
X [ERROR] Could not resolve "canvas"
node_modules/konva/lib/index-node.js:4:23:
4 │ const Canvas = require("canvas");
╵ ~~~~~~~~
You can mark the path "canvas" as external to exclude it from the bundle, which will remove this
error and leave the unresolved path in the bundle. You can also surround this "require" call with
a try/catch block to handle this failure at run-time instead of bundle-time.
1 of 102 errors shown (disable the message limit with --log-limit=0)
ERR! Error bundling shared npm package
ERR! Build failed with 102 errors:
ERR! node_modules/@nodelib/fs.scandir/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
ERR! node_modules/@nodelib/fs.scandir/out/settings.js:3:21: ERROR: Could not resolve "path"
ERR! node_modules/@nodelib/fs.stat/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
ERR! node_modules/@nodelib/fs.walk/out/providers/stream.js:3:25: ERROR: Could not resolve "stream"
ERR! node_modules/@nodelib/fs.walk/out/settings.js:3:21: ERROR: Could not resolve "path"
ERR! ...
ERR! For more information, run in verbose mode
NOTE
NOTE
NOTE ** Important Information: ***
NOTE The error message above shows an issue with bundling a node_module.
NOTE In most cases this is because you (indirectly) shared a Node.js package,
NOTE while Native Federation builds for the browser.
NOTE You can move such packages into devDependencies or skip them in your federation.config.js.
NOTE
NOTE More Details: https://bit.ly/nf-issue
NOTE
NOTE
getting above errors in console while running app using ng serve
Where is your remote running? Is there a second app running configured as remote on localhost:3000
? Can you please share your federation.config.js
file?
Remote app also getting same error
INFO Building federation artefacts
WARN No entry point found for json-server
WARN If you don't need this package, skip it in your federation.config.js or consider moving it into depDependencies in your package.json
WARN No meta data found for shared lib json-server
INFO Preparing shared npm packages
NOTE This only needs to be done once, as results are cached
NOTE Skip packages you don't want to share in your federation config
X [ERROR] Could not resolve "canvas"
node_modules/konva/lib/index-node.js:4:23:
4 │ const Canvas = require("canvas");
╵ ~~~~~~~~
You can mark the path "canvas" as external to exclude it from the bundle, which will remove this
error and leave the unresolved path in the bundle. You can also surround this "require" call with
a try/catch block to handle this failure at run-time instead of bundle-time.
1 of 102 errors shown (disable the message limit with --log-limit=0)
ERR! Error bundling shared npm package
ERR! Build failed with 102 errors:
ERR! node_modules/@nodelib/fs.scandir/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
ERR! node_modules/@nodelib/fs.scandir/out/settings.js:3:21: ERROR: Could not resolve "path"
ERR! node_modules/@nodelib/fs.stat/out/adapters/fs.js:4:19: ERROR: Could not resolve "fs"
ERR! node_modules/@nodelib/fs.walk/out/providers/stream.js:3:25: ERROR: Could not resolve "stream"
ERR! node_modules/@nodelib/fs.walk/out/settings.js:3:21: ERROR: Could not resolve "path"
ERR! ...
ERR! For more information, run in verbose mode
NOTE
NOTE
NOTE ** Important Information: ***
NOTE The error message above shows an issue with bundling a node_module.
NOTE In most cases this is because you (indirectly) shared a Node.js package,
NOTE while Native Federation builds for the browser.
NOTE You can move such packages into devDependencies or skip them in your federation.config.js.
NOTE
NOTE More Details: https://bit.ly/nf-issue
NOTE
NOTE
Initial chunk files | Names | Raw size
styles.css | styles | 1.80 MB |
scripts.js | scripts | 202.32 kB |
polyfills.js | polyfills | 190.65 kB |
main.js | main | 251 bytes |
| Initial total | 2.18 MB
Lazy chunk files | Names | Raw size
chunk-W7BHCA2L.js | lists-module | 17.73 kB |
chunk-3XF6V6UT.js | bootstrap | 14.53 kB |
chunk-JVUHT3BT.js | - | 2.89 kB |
chunk-233JND4H.js | auth-component | 1.00 kB |
Application bundle generation complete. [3.997 seconds]
Watch mode enabled. Watching for file changes...
Re-optimizing dependencies because lockfile has changed
➜ Local: http://localhost:4201/
➜ press h + enter to show help
if i am removing ...shareAll({ singleton: true, strictVersion: true, requiredVersion: 'auto' }),
this line from federation.config.js then app is running. and if i am routing to a mfe from shell i am getting below error
chunk-J4B6MK7R.js?v=af5cb44f:48 ERROR RuntimeError: NG0203: inject() must be called from an injection context such as a constructor, a factory function, a field initializer, or a function used with `runInInjectionContext`. Find more at https://angular.io/errors/NG0203
at injectInjectorOnly (core.mjs:1093:15)
at ɵɵinject (core.mjs:1106:42)
at Object.factory (core.mjs:27822:46)
at core.mjs:3219:47
at runInInjectorProfilerContext (core.mjs:866:9)
at R3Injector.hydrate (core.mjs:3218:21)
at R3Injector.get (core.mjs:3082:33)
at definition.getStandaloneInjector (core.mjs:27838:31)
at ComponentFactory.create (core.mjs:15776:39)
at ViewContainerRef2.createComponent (core.mjs:16265:47)
Promise.then
step @ chunk-J4B6MK7R.js?v=af5cb44f:48
fulfilled @ chunk-J4B6MK7R.js?v=af5cb44f:36
Zone - Promise.then
step @ chunk-J4B6MK7R.js?v=af5cb44f:48
(anonymous) @ chunk-J4B6MK7R.js?v=af5cb44f:49
__async @ chunk-J4B6MK7R.js?v=af5cb44f:33
loadComponent @ app.routes.ts:14
Zone - Promise.then
sidenavigation @ sidenav.component.ts:51
SidenavComponent_For_5_Conditional_2_Template_a_click_0_listener @ sidenav.component.html:98
Zone - HTMLAnchorElement.addEventListener:click
SidenavComponent_For_5_Conditional_2_Template @ sidenav.component.html:97
SidenavComponent_For_5_Template @ sidenav.component.html:13
load
ngOnInit @ sidenav.component.ts:32
Zone - Promise.then
(anonymous) @ bootstrap.ts:5
Did you try to add konva
and canvas
add to the skip
section in your federation.config.js
?
I have converted an existing angular repo to shell app using
ng g @angular-architects/native-federation:init --port 4220 --type dynamic-host
commant and successfuly converted and app running fine no errors in console. but in browser console i am getting import 404 errrorsbelow is my package.json