getting errors importing `node_modules` in a Hook ...
# prisma-whats-new
l
getting errors importing
node_modules
in a Hook function – the function runs and works locally. Any specific way to bundle node_modules into a function? (relevant forum post: https://www.graph.cool/forum/t/how-to-import-node-modules-into-hook-function/1684/2)
m
@logan I'm not sure why but you need your own package.json with your all of your dependencies in your local folder. Do you have that? How are you writing your imports?
l
I do, so I’m trying to write a streaming request…
node-fetch
works for me, it turns out. node’s
request
module wasn’t available… for another module I had to
require
instead of
import
. I’m not sure why exactly 😅
m
yeah that was my next point. It's strange as sometimes you need to write
import * as moment from 'moment'
instead of
import moment from 'moment'
. The second import works in JS ES6 but not in TypeScript. I think it's due to some kind of transpiling on the backend to TypeScript.
👍 1
you need to use
import * as moment from 'moment'
on node modules without a default export.
or you can use
require
l
i see ok.. thank you for the heads up