Third Party Lib Struggle

So, I’m struggling to get a third party javascript library to work. Any help would be greatly appreciated. The library is @google-cloud/language. I installed it per their instructions here:

npm install --save @google-cloud/language

Then, the ionic site here explains that in order to create a shorthand type definition, you create a src/declarations.d.ts file which declares the module as 'declare module ‘theLibraryName’. So, I added this to the declarations.d.ts file:

declare module ‘@google-cloud/language’;

Then, the ionic documentation states that if the external library is a CommonJS Module (which I’m guessing it is since the @google-cloud/language/src/index.js uses the code ‘module.exports = Language;’), that the library should be imported with the syntax ‘import myLib from ‘theLibraryName’;’. So, in my component ts file, I added these statements:

import myLib from ‘@google-cloud/language’;

This is causing the following error to be displayed on my page:

ReferenceError: Invalid left-hand side in assignment
at http://localhost:8100/build/main.js:234555:1
at Object. (http://localhost:8100/build/main.js:234597:3)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:201400:13)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:203301:15)
at webpack_require (http://localhost:8100/build/main.js:20:30)
at Object. (http://localhost:8100/build/main.js:120704:14)
at Object. (http://localhost:8100/build/main.js:120919:30)
at webpack_require (http://localhost:8100/build/main.js:20:30)

Perhaps I’m missing something obvious. I’d love some help on this.


Did you fix it? I’m having the very same issue with the ‘mastercard-locations’ library.