#openai movie idea generator problem

68 messages · Page 1 of 1 (latest)

kindred path
#

so if i upload it to netlify or i run it with live server i get an error as you can see in the img but if i run it with npm run dev or npm start everything works just fine, how can i fix that ?

cosmic cobalt
#

The solution is to use npm run dev or npm start, you're not supposed to use live server when you're importing packages like openai since you're relying on node.js

#

and when you upload to netlify, make sure to include package.json so it knows to install the required packages

kindred path
#

@cosmic cobalt it is included cuz i upload the entire folder like with every other app and its not working when i upload it this is my package.json from the scrim

empty matrix
#

Did you install openai via node?

kindred path
#

yes i did

#

with npm install openai ?

empty matrix
#

Yes

kindred path
#

yep

empty matrix
#

Do this, send the github link of the project and I'll take a look

kindred path
#

ok i'll upload it right now

empty matrix
#

page not found

#

do you have it private?

kindred path
#

NOPE

#

WAIT

#

its private wait

#

@empty matrix Done

empty matrix
#

sec

#

@kindred path import { Configuration, OpenAIApi } from "../openai"; do this and see if it fixes it

kindred path
#

ok wait

#

now i get this, doesn't work in dev enviroment either

empty matrix
#

kk, just wanted to see smth

kindred path
#

ok thanks for trying to help btw

empty matrix
#

const { Configuration, OpenAIApi } = require("openai");

kindred path
#

if i do this the error changes in require is undefined

#

look

#

even in the dev thing

empty matrix
#

hmm, i do not have that error..

#

just a 404 because im not providing a key

kindred path
#

ok wait im uploading it to netlify with a key

#

the key is good now and i still get the 404

#

ok im gonna try something

#

even on netlify

empty matrix
#

idk, sorry x)

kindred path
#

idk what to do 😦

oak ingot
# kindred path idk what to do 😦

Try:

import { Configuration, OpenAIApi } from "openai"

require is common js import syntax and cannot be used with es6 imports.

I haven't been through this project, so the import may brake depending on if openai exports those named functions.

#

Also, try to cd into the project root and run npm install again and see if it helps.

The reason it's likely asking for a relative path is because the bundler isn't handling the node module imports correctly. Which also makes me wonder if vite is actually installed.

#

If the previous import doesn't work after installing again, try changing the import from:

from "openai"

To:

from "./node_modules/openai" 

And see if it fixes it. If it does, I suspect something is wrong with the module bundler for some reason.

kindred path
#

@oak ingot i get this error if i use .node_modules/openai

oak ingot
kindred path
#

i did npm install again

oak ingot
#

And did you try with just import openapi before using node modules path?

kindred path
#

yes i did

#

everything works just fine with npm start

#

or npm run dev

oak ingot
kindred path
#

its working with npm start and npm run dev, just as before but i can't put it on netlify

#

cuz i get that error

oak ingot
kindred path
#

yes, it doesn't work only when i try to put it there or i think on any hosting site

oak ingot
#

And for the scripts that you have run for your deploy, what did you tell netlify to use?

kindred path
#

how do i do that? i just press on deploy and thats it

oak ingot
#

I've never used netlify, but I have used vercel and they have you use your own commands when deploying. Netlify may have a different automation process. I may not be able to help you just this minute.... I'm at work right now putting a dashboard back in a vehicle. When I get home in a little while I'll fork your repo and see if I can deploy it to netlify to find out where the error is. So please be patient with me!

kindred path
#

@oak ingot Thank you so much for trying to help me, if nothing works i can try vercel too, netlify was recomended from scrimba thats why i used it

oak ingot
kindred path
#

@oak ingot thank you for helping me, im trying to upload it to vercel now and see if it works

kindred path
#

i tried to upload it to vercel and i get this error

oak ingot
#

@kindred path The deploy seems to work well for me using your repo. Here is a live site of your project https://fancy-malabi-e6b85a.netlify.app/. I don't really know why it is doing what it is doing. Can you go to site setting for your deploy and and check under continuous deploy and take a screenshot of your "Build Settings"? Also, I noticed that your loading image is broken in deploy.

oak ingot
#

I created a pull request to your repo, I removed the node_modules folder from the repo because it is not needed. I changed a couple of things. If you need any help with it, I will do my best. I just get busy during the day. Though I can be pretty helpful in the evenings. I left a pretty sizable comment on the pull request.

kindred path
#

@oak ingot so i should stop the export of the node_modules ? and about the deploy on netlify, i linked netlify with github and it just took the repository from there and deployed it, i think the problem was that it didn't had any build settings before, its working now, thank you so so much, the only way i could change the deploy settings was by linking my github account and it took the project from there, You are the best, is it ok if i add you on discord? 🙂

#

@oak ingot i read everything from you pull request and thanks for the information, the api key thing about security, i am aware of that but it's just a small project for my portofolio nothing too bad there i guess, the key is using free credits anyway, but thanks for the headsup

#

One question i tried just to see if it works to link another project from github directly and i get an error that an html is missing, but it works fine when i deploy it from my pc directly, should i just upload it normaly or

kindred path
#

@oak ingot sadly the app will not work from now on cuz the api key is revoked, i used the free credits, but thank you so much for your help

oak ingot
#

@kindred path you typically don't push node modules to a repo. Every dependency that someone would need is stored in the package.json. All they would have to do is run npm install. Node modules would be unnecessary. And yes, you are more than welcome to add me.

As far as your other project, I'm not sure. I'm not sure what the error for html missing means. I'd have to see it.

I'm sorry the app stopped working. You could always sign up for a different free email address and use that email address for another round of free credits if you wanted 😀.

oak ingot
kindred path
#

@oak ingot thank you for your help, i'll finish the openai scrim and than i'll start to do something else cuz i don't wanna add something to my portofolio that will stop working when the api key will be revoked, thank you so much for your help once again