skygragon / leetcode-cli

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

Error: ENOENT: no such file or directory #130

Closed ZhaoxiZhang closed 6 years ago

ZhaoxiZhang commented 6 years ago

I follow Installation to install the tool on my Ubuntu 18.04. When I have installed successfully, I try to run the command leetcode version, but I could not get the expected result, here is my problem:

fs.js:122
    throw err;
    ^

Error: ENOENT: no such file or directory, open '/home/zyzhang/.lc/plugins.json'
    at Object.openSync (fs.js:443:3)
    at Object.writeFileSync (fs.js:1205:35)
    at Object.cache.set (/usr/local/lib/node_modules/leetcode-cli/lib/cache.js:22:6)
    at Plugin.save (/usr/local/lib/node_modules/leetcode-cli/lib/plugin.js:77:9)
    at Function.Plugin.save (/usr/local/lib/node_modules/leetcode-cli/lib/plugin.js:206:33)
    at initPlugins (/usr/local/lib/node_modules/leetcode-cli/lib/cli.js:57:12)
    at Object.cli.run (/usr/local/lib/node_modules/leetcode-cli/lib/cli.js:93:3)
    at Object.<anonymous> (/usr/local/lib/node_modules/leetcode-cli/bin/leetcode:3:23)
    at Module._compile (internal/modules/cjs/loader.js:707:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:718:10)

What's more, the following is my detail information:

zyzhang@zyzhang:~$ 
zyzhang@zyzhang:~$ node -v
v11.0.0
zyzhang@zyzhang:~$ npm -v
6.4.1
zyzhang@zyzhang:~$ 

Also, I try to install the tool on my Windows OS,but it get a problem as well.

xxx@DESKTOP-M4HL4KO MINGW64 /e/Programming Design/leetcode-cli (master)
$ leetcode login -l
fs.js:646
  return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
                 ^

Error: ENOENT: no such file or directory, open 'C:\Users\xxx\.lc\plugins.json'
    at Object.fs.openSync (fs.js:646:18)
    at Object.fs.writeFileSync (fs.js:1299:33)
    at Object.cache.set (E:\Programming Design\leetcode-cli\lib\cache.js:22:6)
    at Plugin.save (E:\Programming Design\leetcode-cli\lib\plugin.js:77:9)
    at Function.Plugin.save (E:\Programming Design\leetcode-cli\lib\plugin.js:206:33)
    at initPlugins (E:\Programming Design\leetcode-cli\lib\cli.js:57:12)
    at Object.cli.run (E:\Programming Design\leetcode-cli\lib\cli.js:93:3)
    at Object.<anonymous> (E:\Programming Design\leetcode-cli\bin\leetcode:3:23)
    at Module._compile (module.js:653:30)
    at Object.Module._extensions..js (module.js:664:10)

the information on Windows

$ node -v
v8.12.0

$ npm -v
6.4.1
nightwolf-chen commented 6 years ago

You need to add the missing file to '/home/zyzhang/.lc/plugins.json', just create an empty file contains

{}

That works for me.

lzl124631x commented 6 years ago

Same issue. I think the cli should create it rather than throwing unfriendly error for new user.

pengyu-hou commented 6 years ago

Thanks @nightwolf-chen. It works for me by adding the file manually.. But it would be great if the script could have automated it

DemiJiang33 commented 6 years ago

@nightwolf-chen Thank you !

skygragon commented 6 years ago

Fixed it in latest commit, will be included in next release.

Before that, please use the workaround above or try the latest dev code.