skygragon / leetcode-cli

A cli tool to enjoy leetcode!
MIT License
3.65k stars 457 forks source link

Error: Cannot find module 'sqlite3' #122

Open wnykuang opened 6 years ago

wnykuang commented 6 years ago

Problem Summary

当调用了chrome 插件之后,使用leetcode test,会产生 Error: Cannot find module 'sqlite3' 的错误。

[After using chrome plug-in, if we use the "leetcode test"] [Will generate the Error: Cannot find module 'sqlite3']

报错全文: Summary of Error: Error: Cannot find module 'sqlite3' at Function.Module._resolveFilename (internal/modules/cjs/loader.js:581:15) at Function.Module._load (internal/modules/cjs/loader.js:507:25) at Module.require (internal/modules/cjs/loader.js:637:17) at require (internal/modules/cjs/helpers.js:20:18) at Object.Chrome.getCookies (/usr/local/lib/node_modules/leetcode-cli/lib/plugins/cookie.chrome.js:132:17) at Plugin.plugin.signin (/usr/local/lib/node_modules/leetcode-cli/lib/plugins/cookie.chrome.js:160:6) at Plugin.plugin.login (/usr/local/lib/node_modules/leetcode-cli/lib/plugins/cookie.chrome.js:177:10) at Plugin.plugin.relogin (/usr/local/lib/node_modules/leetcode-cli/lib/plugins/retry.js:74:8) at _cb (/usr/local/lib/node_modules/leetcode-cli/lib/plugins/retry.js:49:16) at /usr/local/lib/node_modules/leetcode-cli/lib/plugins/leetcode.js:278:19

After delete the plugin(cookie.chorme) everything went well.

How to reproduce

  1. leetcode test 208.implement-trie-prefix-tree.python3.py
  2. as above described

Environment

ilaskaev commented 6 years ago

I have encountered the same issue on my end. It comes from the cookie.chrome plugin.

I had errors during the build process even though leetcode-cli says that the installation was successful.

I was on windows, but the required version of node-ffi would not build for me. I solved it by using a previous version and manually installing the dependencies for cookie.chrome.

npm install --save node-ffi/node-ffi#169773d ref ref-struct sqlite3 --verbose --python=python2.7
cosmozhang commented 6 years ago

Same error here.

skygragon commented 6 years ago

@z0re the error implies sqlite3 library is not installed successfully. Have u tried install cookie.chrome again?

cosmozhang commented 5 years ago

Is there any solution to this issue? It still remains..

ilaskaev commented 5 years ago

Is there any solution to this issue? It still remains..

Have you attempted my solution? I had to run it inside the leetcode-cli root directory. It additionally required py2.7 to run.

cosmozhang commented 5 years ago

where is leetcode-cli root directory? I have not tried..

ilaskaev commented 5 years ago

where is leetcode-cli root directory? I have not tried..

I was able to find it by typing which leetcode in the terminal, opening up that directory and then opening up node_modules/leetcode-cli from there. You should see the source code for the project there. From there, you can run the command I mentioned in

https://github.com/skygragon/leetcode-cli/issues/122#issuecomment-437051608

cosmozhang commented 5 years ago

Thanks! I will try! What is your OS?

cosmozhang commented 5 years ago

On MAC, it does not work...

skygragon commented 5 years ago

@cosmozhang you could try remove the node_modules folder in the leetcode-cli root folder and reinstall all 3rd party libraries. Below is what I did on my mac:

$ cd /usr/local/lib/node_modules/leetcode-cli
$ rm -rf node_modules && npm install
cosmozhang commented 5 years ago

Tried, but still not working..

ilaskaev commented 5 years ago

Tried, but still not working..

When I had the issue, before finding a fix for it (https://github.com/skygragon/leetcode-cli/issues/122#issuecomment-437051608) I was able to make it work by deleting (or disabling, I don't quite remember) the cookie.chrome plugin. cookie.firefox may possibly cause the same issue, though I am unsure and just guessing at this point. Although not ideal, at least it would let you use the CLI for the time being.

First try disabling the plugin and then if that doesn't work, deleting it. This can be done with

#disable
leetcode plugin -d cookie.chrome

#delete
leetcode plugin -D cookie.chrome

For more info on plugins check out the plugins repo.

@skygragon When I experienced this issue, I noticed that during the installation process of the plugins, everything was reported as having been installed correctly by the CLI, yet when ran in verbose mode, it was clear that some dependencies failed to install.

cosmozhang commented 5 years ago

Yeah, I know. By disabling cookie.chrome leetcode plugin -d cookie.chrome it works. But then I have to login into my account each time when I have used CLI if I want to read the discussion.

ilaskaev commented 5 years ago

Yeah, I know. By disabling cookie.chrome leetcode plugin -d cookie.chrome it works. But then I have to login into my account each time when I have used CLI if I want to read the discussion.

Were there any errors during the installation process of the dependencies for the plugins as in https://github.com/skygragon/leetcode-cli/issues/122#issuecomment-437051608?

cosmozhang commented 5 years ago

I did not use the verbose mode. I will try to re-install and report back later.

kgfly commented 5 years ago

+1 for the issue on Windows 10 Node version: v10.16.0. Both x86 / x64 bit node can repro.