'Svelte how to import
I am working on my first svelte project and are trying to use google-api-wrapper
with the only change being that i import: import Google from "google-api-wrapper";
Then, the troubles started. First was a missing @rollup/plugin-json
, which i added.
This resulted:
Uncaught ReferenceError: fs is not defined
(!) Missing shims for Node.js built-ins
Creating a browser bundle that depends on "querystring", "stream", "url", "assert", "https", "util", "events", "os", "path" and "buffer". You might need to include https://github.com/snowpackjs/rollup-plugin-polyfill-node
LiveReload enabled
(!) Missing global variable names
Use output.globals to specify browser global variable names corresponding to external modules
fs (guessing 'fs')
child_process (guessing 'child_process_1')
querystring (guessing 'querystring')
stream (guessing 'stream')
url (guessing 'url')
net (guessing 'net')
tls (guessing 'tls$1')
assert (guessing 'assert')
https (guessing 'https')
util (guessing 'util$1')
events (guessing 'require$$1')
os (guessing 'os')
path (guessing 'path')
crypto (guessing 'crypto$4')
buffer (guessing 'buffer')
and i also get this error, rather than rendering my site:Uncaught ReferenceError: fs is not defined
Solution 1:[1]
It is basically not possible to use the library google-api-wrapper
with svelte since it is a NodeJS wrapper of the Google Drive and Sheets APIs hence the dependency of fs
(a NodeJS library for local file IO).
I would recommend using the Drive or Sheets API directly. If you want to make parsing a bit easier you can use a library like papaparse
.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|---|
Solution 1 | cascading-jox |