gragland / chatgpt-chrome-extension

A ChatGPT Chrome extension. Integrates ChatGPT into every text box on the internet.
MIT License
2.83k stars 455 forks source link

Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'dotenv-safe' #19

Open Stanley050677 opened 1 year ago

Stanley050677 commented 1 year ago

Hi, I try to get your chrome extension. I got to:

Run the server so the extension can communicate with ChatGPT.

node server.js

and got: Error [ERR_MODULE_NOT_FOUND]: Cannot find package 'dotenv-safe'

How to fix it?

Regards

gragland commented 1 year ago

Did you run npm install before running the server?

Stanley050677 commented 1 year ago

ok, I fixed it :)

now I have different error :

bash-3.2$ node "/Users/stanislawjanusz/chatgpt-chrome-extension/chatgpt-chrome-extension/server.js"

/Users/stanislawjanusz/chatgpt-chrome-extension/node_modules/dotenv-safe/index.js:31 throw new MissingEnvVarsError(allowEmptyValues, options.path || '.env', example, missing, dotenvResult.error); ^ MissingEnvVarsError: The following variables were defined in .env.example but are not present in the environment: OPENAI_EMAIL, OPENAI_PASSWORD Make sure to add them to .env or directly to the environment.

If you expect any of these variables to be empty, you can use the allowEmptyValues option: require('dotenv-safe').config({ allowEmptyValues: true });

Also, the following error was thrown when trying to read variables from .env: ENOENT: no such file or directory, open '/Users/stanislawjanusz/chatgpt-chrome-extension/.env' at Object.config (/Users/stanislawjanusz/chatgpt-chrome-extension/node_modules/dotenv-safe/index.js:31:19) at file:///Users/stanislawjanusz/chatgpt-chrome-extension/chatgpt-chrome-extension/server.js:2:8 at ModuleJob.run (node:internal/modules/esm/module_job:194:25) { missing: [ 'OPENAI_EMAIL', 'OPENAI_PASSWORD' ], sample: '.env.example', example: '.env.example' }

Node.js v18.13.0

I did made the .env file and put .env.example file inside with my email and password.

dwreski commented 1 year ago

Same problem here. Is it no longer necessary to set SESSION_TOKEN? Those steps seem to have been removed.

gragland commented 1 year ago

Same problem here. Is it no longer necessary to set SESSION_TOKEN? Those steps seem to have been removed.

Yes we now use an email and password, as required by the latest version of the ChatGPT auth library we use (https://github.com/transitive-bullshit/chatgpt-api)

dwreski commented 1 year ago

Same problem here. Is it no longer necessary to set SESSION_TOKEN? Those steps seem to have been removed.

Yes we now use an email and password, as required by the latest version of the ChatGPT auth library we use (https://github.com/transitive-bullshit/chatgpt-api)

okay, I have installed chatgpt-api ("npm install chatgpt puppeteer") within the same directory as chatgpt-chrome-extension, updated .env with my email/pass and run "node server.js". It produces a chrome pop-up, then fails after some time with:

/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:174
    return new Errors_js_1.TimeoutError(errorMessage);
           ^
TimeoutError: Navigation timeout of 30000 ms exceeded
    at LifecycleWatcher._LifecycleWatcher_createTimeoutPromise (/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/com
mon/LifecycleWatcher.js:174:12)

Node.js v18.12.1
gragland commented 1 year ago

Same problem here. Is it no longer necessary to set SESSION_TOKEN? Those steps seem to have been removed.

Yes we now use an email and password, as required by the latest version of the ChatGPT auth library we use (https://github.com/transitive-bullshit/chatgpt-api)

okay, I have installed chatgpt-api ("npm install chatgpt puppeteer") within the same directory as chatgpt-chrome-extension, updated .env with my email/pass and run "node server.js". It produces a chrome pop-up, then fails after some time with:

/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:174
    return new Errors_js_1.TimeoutError(errorMessage);
           ^
TimeoutError: Navigation timeout of 30000 ms exceeded
    at LifecycleWatcher._LifecycleWatcher_createTimeoutPromise (/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/com
mon/LifecycleWatcher.js:174:12)

Node.js v18.12.1

The command should only be npm install (not npm install chatgpt puppeteer). Can you delete your node_modules directory and then try that command again?

dwreski commented 1 year ago

Still fails with a similar error, but a few more details.

$ node server.js 
/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:174
    return new Errors_js_1.TimeoutError(errorMessage);
           ^

TimeoutError: Navigation timeout of 30000 ms exceeded
    at LifecycleWatcher._LifecycleWatcher_createTimeoutPromise (/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/common/LifecycleWatcher.js:174:
12)
    at async Frame.goto (/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Frame.js:206:21)
    at async CDPPage.goto (/home/dave/chatgpt-chrome-extension-main/node_modules/puppeteer-core/lib/cjs/puppeteer/common/Page.js:439:16)
    at async getOpenAIAuth (file:///home/dave/chatgpt-chrome-extension-main/node_modules/chatgpt/build/index.js:827:5)
    at async ChatGPTAPIBrowser.initSession (file:///home/dave/chatgpt-chrome-extension-main/node_modules/chatgpt/build/index.js:1378:24)
    at async file:///home/dave/chatgpt-chrome-extension-main/server.js:17:1

Node.js v18.12.1

The pop-up also prints an error at the top: You are using an unsupported command-line flag: --disable-setuid-sandbox. Stability and security will suffer

This is on fedora37 with all most recent updates and Chrome Version 109.0.5414.74 (Official Build) (64-bit). Thanks so much for your help.

gragland commented 1 year ago

@dwreski Not sure what could be causing that.. Works for me on a Mac. Hopefully someone else can chime in with a fix.

dwreski commented 1 year ago

@gragland looks like this bug? https://github.com/puppeteer/puppeteer/issues/8829

$ npm --version 8.19.2

$ node --version v18.12.1

Just to be sure, the only things I have to do is download chatgpt-extension-main, enter my OPENAI_EMAIL and OPENAI_PASSWORD into .env, run "npm install" in that directory, then "node server.js" correct?