Cannot compile app when importing `docker-registry-client`
Closed this issue · 2 comments
I cloned the repo repo and installed docker-registry-client
, then added this line to App.tsx
:
import * as client from "docker-registry-client"
console.log("client", client)
And I get this error when compiling (npm run dev
in that project):
ERROR in ./~/asn1.js-rfc3280/index.js
Module not found: Error: Cannot resolve 'file' or 'directory' ../.. in /Users/abeall/tools/docker-manager/electron/node_modules/asn1.js-rfc3280
@ ./~/asn1.js-rfc3280/index.js 4:13-34
The error only appears when I try to import docker-registry-client
. Any idea?
This is a problem with the asn1.js-rfc3280
module, which doesn't seem to work nicely with webpack.
The problem is the fallback require("../" + "..")
. Webpack is supposed to ignore that, but it is sadly smart enough to evaluate the expression "../" + ".."
and tries to import it (sadly it's not smart enough to detect that this require will never be needed).
Long story short, here's how you could fix this. Add this block to your webpack.config.base.js
:
externals: [
{
"../..": "asn1"
}
]
Let me know if that works for you. 😸
@iRath96 Thank-you for the explanation, I will give it a try!