1

I want to use the EPSON JavaScript SDK in my vue (2.6.14) app. I tried to import die epson js file like this:

import epson from '../../public/epos-2.18.0'

Importing the script will result in a parsing error

4:103598  error  Parsing error: Deleting local variable in strict mode.

I found something similar here: babel-loader: Module build failed: SyntaxError: Deleting local variable in strict mode, but that did not help me at all.

Is there any common approach to import library's like that?

fgdh
  • 11
  • 2
  • It's unlikely it's a module, so it may make no sense to import it as `epson`. See newer posts in https://stackoverflow.com/questions/33821312/how-to-remove-global-use-strict-added-by-babel , as older ones apply to old Babel versions . You can always put it to public and load as any other third-party script. – Estus Flask Oct 19 '21 at 07:48
  • With "load as any other thrid-party script" do you mean that i load it inside my index.html with a tag? – fgdh Oct 19 '21 at 08:07
  • Either that, or add script tag dynamically, e.g. with vue-plugin-load-script – Estus Flask Oct 19 '21 at 08:23
  • I've tried this first, if I do that, and use epson like `var ePosDev = new epson.ePOSDevice();` it will tell me that epson is not defined. – fgdh Oct 19 '21 at 08:29
  • Either a script didn't load, or something else happened. – Estus Flask Oct 19 '21 at 08:32
  • I loaded the script sucessfully with `Vue.loadScript("http://localhost:8001/epos-2.18.0.js") .then(() => { var ePosDev = new epson.ePOSDevice(); console.log(ePosDev) }) .catch(() => { });` The log shows me the loaded ePOSDevice. But anyways.. I still getting this error: `Failed to compile. ./main.js Module Error (from /usr/local/lib/node_modules/@vue/cli-service-global/node_modules/eslint-loader/index.js): /path/to/project/src/main.js 60:21 error 'epson' is not defined no-undef ✖ 1 problem (1 error, 0 warnings)` – fgdh Oct 19 '21 at 09:08
  • It's linter error, not a real one. You can disable no-undef rule, or use window.epson – Estus Flask Oct 19 '21 at 09:10
  • Now it seems to work for me, you helped me a lot! Thank you! – fgdh Oct 19 '21 at 09:13

0 Answers0