Closed mlncstr closed 5 years ago
Hi,
I could forward a complete code example to one of or developers. Please send your code and we can maybe have a look.
But for my understanding, why are you not using it with the following code:
const tinify = require("tinify");
Let me know!
Kind regards,
Michiel Verkoijen
tinify/tinify-nodejs on January 31, 2019 at 9:54pm wrote:
Trying to import via:
import * as tinify from 'tinify'
But getting:
ERROR in node_modules/tinify/lib/tinify/Error.d.ts(1,36): error TS2304: Cannot find name 'global'.
Any ideas?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub ( https://github.com/tinify/tinify-nodejs/issues/21 ), or mute the thread ( https://github.com/notifications/unsubscribe-auth/AVWuQCG6W2ORHM0BLBp8lAt8mAI_QJzWks5vI1ftgaJpZM4adImk ) .
The proper convention with angular is to include modules via import because require breaks AOT compilation.
Is there a unified version of tinify.js accessible via CDN by chance?
Hey,
I've come across the same issue, tho I did manage to resolve that initial global import with:
declare let global: any;
in the Error.d.ts file
but after that I got a ton of new errors regarding imports for "fs" & "http/s"
Module not found: Error: Can't resolve '_http_client' in ' / node_modules / proxying - agent / lib'
ERROR in ./ node_modules / proxying - agent / lib / ntlm.js
Module not found: Error: Can't resolve 'crypto' in ' / node_modules / proxying - agent / lib'
ERROR in ./ node_modules / tinify / lib / tinify / compat.js
Module not found: Error: Can't resolve 'fs' in ' / node_modules / tinify / lib / tinify'
ERROR in ./ node_modules / tinify / lib / tinify / Client.js
Module not found: Error: Can't resolve 'fs' in ' / node_modules / tinify / lib / tinify'
ERROR in ./ node_modules / proxying - agent / lib / proxying - agent.js
Module not found: Error: Can't resolve 'http' in ' / node_modules / proxying - agent / lib'
ERROR in ./ node_modules / proxying - agent / lib / proxying - agent.js
Module not found: Error: Can't resolve 'https' in ' / node_modules / proxying - agent / lib'
ERROR in ./ node_modules / tinify / lib / tinify / Client.js
Module not found: Error: Can't resolve 'https' in ' / node_modules / tinify / lib / tinify'
ERROR in ./ node_modules / proxying - agent / lib / proxying - agent.js
Module not found: Error: Can't resolve 'os' in ' / node_modules / proxying - agent / lib'
ERROR in ./ node_modules / proxying - agent / lib / proxying - agent.js
Module not found: Error: Can't resolve 'tls' in ' / node_modules / proxying - agent / lib'```
Can anybody point me in the right direction?
I'm using Angular 6 & node 10.15
Hi there,
Angular is a front-end framework. This is a NodeJS library and you need to use it server side (back-end). Unfortunately the API does not support being used in the front-end (like Angular does). The reason being that it would make it hard to hide sensitive data from the user (like you API key).
In short, this will not be usable with just Angular. You would need a back-end to handle the compressions. What I would recommend is posting the image from your Angular application to the server and have the server import Tinify and deal with the compression. You can then return the compressed image to the Angular application if you want to give it back to the user.
Hope this clears up the issue!
Thanks Simon, understood about this intending for strictly backend node use. We were trying to see if we could convert the node version into a front-end usable component (we've actually done that in the past with other plugins).
Either way, appreciate the response!
Trying to import via:
import * as tinify from 'tinify'
But getting:
ERROR in node_modules/tinify/lib/tinify/Error.d.ts(1,36): error TS2304: Cannot find name 'global'.
Any ideas?