Print.js: Module not found: 'print.js'
I’m trying to import the lib in es6 like this:
import printJS from 'print.js'
printJS()
But I get:
Uncaught Error: Cannot find module "print.js"
at webpackMissingModule
Tried it on the latest v1.0.18 version
About this issue
- Original URL
- State: closed
- Created 7 years ago
- Reactions: 4
- Comments: 29 (9 by maintainers)
@Kuchiriel I had the same issue, maybe this helps you as well:
@nsksaisaravana @nicolas-schreiber , Thanks for pointing this error. It has been fixed. Run
npm update print-jsto get the new release. It was just published. Please let me know if you still get any errors after that. Thx again.@crabbly I am trying to import the full path, and the problem stills.
Hey @slyfalcon ,
The problem with your code is this:
import printJS from 'print-js'When you do that inside the same file where you are calling the function, you had replaced the global variable
printJSwith the module import, creating the above error.Use
import 'print-js'instead. Or obviously, any other name, like for ex.import print form 'print-js'.Thanks @crabbly , it works! Finally, it looks like this, (Note: please ignore the vscode warning)
import 'print-js'...printJS({ printable: [{ name: 'alex', age: '11' }], properties: ['name', 'age'], type: 'json' });...@crabbly Thanks a lot and works like charm, saved my day.
@SpencerCarstens Exactly. Importing the full path works fine. Thx for the feedback. Once I have renamed the package it will be easier though. I’ll post an update here soon.
import printJS from 'node_modules/print.js/src/index.js';Works fine.