-
Notifications
You must be signed in to change notification settings - Fork 33
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Cannot find module dasu #14
Comments
I will re try this on vercel now and let you know |
Halåj~ Which version are you using and which npm and node versions? |
Was this issue resolved? |
I also got this error, when I used this library in next.js api and deploy it to vercel. error:
version:
|
Can you show the context of where it's being used in the code? |
I use this library in the following way in nextjs lambda api. pages/api/yt.ts const yts = require("yt-search");
import { NextApiRequest, NextApiResponse } from 'next'
export default async (req: NextApiRequest, res: NextApiResponse) => {
const {
query: { q },
} = req;
try {
const r = await yts(q);
res.status(200).json(r.videos);
} catch (e) {
console.log(e);
}
} |
Thanks~ I can reproduce the issue, I'm looking into it. |
Update: I haven't solved the issue yet, but it seems to be related to the lambda api is installed in vercel/next. Even though vercel/next claims the lambdas use the package-json.lock and npm it is still failing to resolve the dependencies. I'm not sure if they are not downloaded at all or if it's a problem in how they resolve the dependencies. Usually lamdas load all their data from a zip file direclty. But given that they apparently support npm modules and pacakge.json's they may be doing some tricky things behind the scenes that are failing. It is unclear as of yet. The static pre-fetching works fine as you can see here: https://vercel-next-yt-search-test-hcxf6c9i7.vercel.app ( youtube video title inserted dynamically below the header ) |
Update2: I've been in contact with vercel support and trying to resolve the issue. As a side note, here's an example of using yt-search in aws lambda: https://github.com/talmobi/yt-search-lambda example api url: https://69v539djw3.execute-api.us-east-1.amazonaws.com/default/yt-search-api-lambda?search=superman+theme |
@talmobi Thanks a lot!!! |
@yareyaredesuyo wow! you're right! I can reproduce that it's working with the non-minified version (example: https://vercel-next-yt-search-test-127g4hwhu.vercel.app/api/hello). Not sure what's going on but looks like perhaps uglifyJS is doing something that prevents the vercel/next lambda loader from recognizing or loading modules properly. Or something like that. Not sure if it's an issue with uglifyJS or the vercel/next lambda loader. Not sure what to do about it yet. Nice catch! |
I'm leaning towards simply skipping the minified version altogether, regardless if it's an issue with uglify-js or vercel/next. Thoughts or suggestions? |
I think, if you want to deliver both versions, you should set not minified version for main, and minified version for another (like setting jsdelivr). And this is very standard way, because it's a bit hard for debugging minified libs and tracking errors. Sample implementation: "main": "index.js",
"jsdelivr": "dist/axios.min.js",
"unpkg": "dist/axios.min.js", And I think this is very tiny lib, not so much need for uglifying (also uglify is a bit obsolated, and you should think about switching using library like terser, ncc. switching example: twbs/bootstrap#27813). refs: https://stackoverflow.com/questions/48673408/should-javascript-npm-packages-be-minified |
affect some third-party module resolution strategies. ref: #14 problem: the uglify-js minified bundle seems to prevent some third-party module detection/resolution from working properly. Particularly vercel and its lambda loader. see: #14 solution: use non-minified bundle instead. Size difference is negligible as this is a backend/server-side bundle and it will help out with debugging also.
Hi, I am experiencing an issue on vercel where it says in cannot find module dasu, I normally works locally. So it does not make sense. I am thinking its something to do the how that module is packaged.
Do you have any ideas?
The text was updated successfully, but these errors were encountered: