Maybe this will help someone but I am needing to u...
# help
r
Maybe this will help someone but I am needing to use
node-fetch
in my project so I installed it like normal
npm i node-fetch
. This gave me v3 which is
type: module
only. This should be fine as I am using a TS project and it shouldn't matter much. However I kept getting an error with SST telemetry as it also uses
node-fetch
Copy code
node_modules/@serverless-stack/core/dist/telemetry/post-payload.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module"
``` I disabled telemetry in my SST project but sadly this file still seems to load and cause the error. So for now the only option is to stick with for node-fetch@2. Anyway hope this helps someone.
t
ah that's annoying
@Frank should we just use the native
https
module? Think our situation is simple enough
r
little bit, but i blame the insanity of cjs/esm 🙂 we will get there soon enough when the world is all esm
f
@thdxr i created a new SST app and I’m looking at the
yarn.lock
file, it seems there are a couple other packages that depends on
node-fetch
. Will removing
node-fetch
in telemetry fix the issue?
t
Hm what else depends on it? It's possible they're shipping esm
f
@mapbox/node-pre-gyp @serverless-stack-slack/cli apollo-server-env next
c
Seems I got the exact same problem with a fresh install of SST + TS. Telemetry prevents me to move to node-fetch 3 and stick to 2.6.7
t
fyi node-fetch was removed from our deps