flow / flow-for-vscode

Flow for Visual Studio Code
Other
994 stars 111 forks source link

Enabling use LSP crashes the extension with Error: Cannot find module 'is-utf8' since updating to 0.8.4 #272

Closed LaurensBosscher closed 5 years ago

LaurensBosscher commented 6 years ago

I restarted VSCode and since then I've been getting the following error:

Error: Cannot find module 'is-utf8'
    at Function.Module._resolveFilename (module.js:543:15)
    at Function.Module._load (module.js:473:25)
    at Module.require (module.js:586:17)
    at require (internal/module.js:11:18)
    at Object.<anonymous> (/Users/laurensbosscher/.vscode/extensions/flowtype.flow-for-vscode-0.8.4/node_modules/strip-bom/index.js:2:14)
    at Object.<anonymous> (/Users/laurensbosscher/.vscode/extensions/flowtype.flow-for-vscode-0.8.4/node_modules/strip-bom/index.js:19:3)
    at Module._compile (module.js:642:30)
    at Object.Module._extensions..js (module.js:653:10)
    at Module.load (module.js:561:32)
    at tryModuleLoad (module.js:504:12)
[Info  - 2:30:43 PM] Connection to server got closed. Server will restart.
module.js:545
    throw err;

Disabling LSP does fix the error. Everything used to work until the extension was updated today. I've looked through the commits but unfortunately, I cannot explain where "is-utf8" or "strip-bom" is used in this extension.

Flow version:

flow version
Flow, a static type checker for JavaScript, version 0.80.0

VSCode version:

1.27.1 (1.27.1)

Thanks!

NameFILIP commented 6 years ago

I've seen it earlier and mitigated it by running

cd ~/.vscode/extensions/flowtype.flow-for-vscode-0.8.4/
yarn
LaurensBosscher commented 6 years ago

Thanks that took care of the problem!

NameFILIP commented 6 years ago

I noticed that when hovering over the error it was blinking every second though, so I had to disable LSP as well.

carmanchris31 commented 6 years ago

I had the same issue even after turning LSP off and restarting, etc. Running yarn manually as @NameFILIP described mitigated the problem for me as well.

orta commented 6 years ago

Yeah - this is pretty weird, there are no changes to the package.json (outside of a typo fix and version bump) in the last version

kumarharsh commented 6 years ago

edit: nevermind, the error is coming from within a sub-dependency which I misread. The is-utf8 is there in yarn.lock.

The is-utf8 is not in the package.json dependencies of the installed plugin. The list is:

{
    "name": "flow-for-vscode",
    "version": "0.8.4",
    "dependencies": {                            
        "cross-spawn": "^4.0.0",             
        "dequeue": "^1.0.5",                 
        "elegant-spinner": "^1.0.1",         
        "event-kit": "^2.0.0",               
        "flow-bin": "^0.68.0",               
        "flow-language-server": "^0.6.0",    
        "fs-plus": "^2.8.2",                 
        "fuzzaldrin": "^2.1.0",              
        "js-beautify": "^1.6.12",            
        "lodash.debounce": "^4.0.8",         
        "log4js": "^0.6.37",                 
        "lru-cache": "^4.0.1",               
    }
}
TheAifam5 commented 6 years ago

@NameFILIP I've done this also but:

nuclide-flow-rpc - Flow IDE process stderr:  Could not find a .flowconfig in . or any of its parent directories.
See "flow init --help" for more info

[2018-11-15 21:34:58.544] [ERROR] nuclide-commons/process - stream error on stream stdin with command: /home/theaifam5/.config/yarn/global/node_modules/flow-bin/flow-linux64-v0.86.0/flow [ 'ide',

The file does NOT exists btw, but I think ,this error message should be not printed as an error, but as a information that the file is missing or something.

carmanchris31 commented 6 years ago

Had this issue again and came back to this thread. Version is now 0.8.5 so I had to update the path in @NameFILIP's workaround:

cd ~/.vscode/extensions/flowtype.flow-for-vscode-0.8.5/
yarn
Mayank1791989 commented 5 years ago

Update plugin to >= 1.0.0. It's fixed now.