I have a next.js
project and I keep getting:
error - ./node_modules/jspdf/dist/jspdf.es.min.js:458:25
Module not found: Can't resolve 'canvg'
I'm not sure why because I'm not including either jspdf
or canvg
.
Not sure what's causing it. Any help would be appreciated. I'm using material-ui
if that matters.
I have a next.js
project and I keep getting:
error - ./node_modules/jspdf/dist/jspdf.es.min.js:458:25
Module not found: Can't resolve 'canvg'
I'm not sure why because I'm not including either jspdf
or canvg
.
Not sure what's causing it. Any help would be appreciated. I'm using material-ui
if that matters.
-
If you do
npm ls jspdf
that should help you determine what has it as a dependency. – Jacob Commented Oct 29, 2020 at 0:17 -
4
@shamoon could you share your
package.config
file? – Dipen Shah Commented Oct 29, 2020 at 1:03
2 Answers
Reset to default 4It seems dependency error means that particular Module is missing when it's running.
Run npm ls or yarn list
will print to stdout all the versions of packages that are installed, as well as their dependencies, in a tree-structure. Then search for that particulate packages are listed or not.
Run npm ls jspdf or yarn list jspdf
then you can see its list of dependencies in tree-structure.
Please check your node
version is updated or not ? If not then update first.
Quick & Dirty way: delete package.lock or yarn.lock
file and delete .node_modules
folders And Then run npm install or yarn
to install again.
Look at console while you installing and make sure there are no error in the installing process. If you saw error you better look that massages also.
In my case, I was using react-pdf
, which supposedly has canvg
as an optional dependency (it or one of its dependencies) even though it was apparently required during a yarn build
.
At first, I installed my dependencies using yarn install --frozen-lockfile --ignore-optional
in a pipeline and I got that error.
I simply removed the --ignore-optional
flag and now my install script is working.