leetcode-cli icon indicating copy to clipboard operation
leetcode-cli copied to clipboard

Error: Cannot find module 'sqlite3'

Open wnykuang opened this issue 6 years ago • 16 comments

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

  • leetcode-cli version: 2.5.2
  • OS version: macOS 10.13.6
  • Node version:
  • Npm version: 6.2.0
  • cookie.chrome version: 2018.05.30

wnykuang avatar Sep 08 '18 02:09 wnykuang

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

ilaskaev avatar Nov 08 '18 16:11 ilaskaev

Same error here.

cosmozhang avatar Nov 10 '18 20:11 cosmozhang

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

skygragon avatar Nov 18 '18 08:11 skygragon

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

cosmozhang avatar Dec 02 '18 23:12 cosmozhang

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.

ilaskaev avatar Dec 02 '18 23:12 ilaskaev

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

cosmozhang avatar Dec 02 '18 23:12 cosmozhang

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

ilaskaev avatar Dec 03 '18 00:12 ilaskaev

Thanks! I will try! What is your OS?

cosmozhang avatar Dec 03 '18 01:12 cosmozhang

On MAC, it does not work...

cosmozhang avatar Dec 03 '18 01:12 cosmozhang

@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

skygragon avatar Dec 03 '18 14:12 skygragon

Tried, but still not working..

cosmozhang avatar Dec 03 '18 16:12 cosmozhang

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.

ilaskaev avatar Dec 03 '18 16:12 ilaskaev

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.

cosmozhang avatar Dec 03 '18 17:12 cosmozhang

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?

ilaskaev avatar Dec 03 '18 17:12 ilaskaev

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

cosmozhang avatar Dec 03 '18 17:12 cosmozhang

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

kgfly avatar May 29 '19 06:05 kgfly