monaco-vim
monaco-vim copied to clipboard
'shiftCommand.js not found' + 'Duplicate definition of module shiftCommand'
Hi, I've got monaco-vim implemented exactly how it is in the demo, but I am running into a few issues.
Firstly, on every launch I am getting this error in my JS console:
loader.js:698 GET file:////path/to/project/node_modules/monaco-editor/min/vs/editor/common/commands/shiftCommand.js net::ERR_FILE_NOT_FOUND
loader.js:280 Loading "vs/editor/common/commands/shiftCommand" failed
loader.js:281 Error: [object Event]
at Object.E [as ensureError] (loader.js:263:22)
at s._createLoadError (loader.js:1515:33)
at s._onLoadError (loader.js:1526:30)
at c (loader.js:1672:27)
at Object.errorback (loader.js:1692:25)
at e.triggerErrorback (loader.js:639:36)
at loader.js:626:151
at HTMLScriptElement.c (loader.js:662:17)
However, everything still appears to work, regardless of this error. I'm not totally sure what this error means, but I have verified myself that the folder it's searching for shiftCommand.js doesn't even exist. It is located in /esm/vs/editor/common/commands/shiftCommand.js whereas, per the error message, it's looking in /min/vs/editor/common/commands/shiftCommand.js even though there is no common folder in /min/vs/editor
Secondly, I occasionally get a different error, and this one actually causes monaco to not load at all and just gives me a white screen, sometimes requiring me to reload several times before it will work
Duplicate definition of module 'vs/editor/common/commands/shiftCommand'
It seems completely random when this happens, and sometimes I have to reload 3 or 4 times before it'll go away and work normally.
Something is up with shiftCommand and I'm not sure what or where to begin with fixing it. I'd appreciate any help.
I should state that I'm super new to Electron, Node, etc, so I barely know how I got this cobbled together. I'm used to Python and C so I'm a bit lost.
Just for kicks I decided just now to try creating the '/vs/editor/common/commands/folder and copyingshiftCommand.js` into it and now the only error message I get in the console is
Uncaught SyntaxError: Cannot use import statement outside a module (at shiftCommand.js:5:1)
But everything else still seems to be working fine, and I refreshed about a hundred times and didn't get the duplicate definition error. I suppose it's a good enough workaround for now.
Seems like you are using AMD / requirejs type loader. Did you follow the amd instructions in the readme. Or could you paste the code snippet of how you are loading monaco vim
Seems like you are using AMD / requirejs type loader. Did you follow the amd instructions in the readme. Or could you paste the code snippet of how you are loading monaco vim
I am using AMD loader, yeah, but not for any reason. Since this is my first Electron project, I have no preference, AMD seems like the first that most guides recommend, so I went with that.
Here is a gist of my Monaco <script> section
From what I can tell, I followed the instructions exactly. It's likely user error, due to my lack of understanding of how node modules work, but I would appreciate it if you had any advice or ideas of how to fix it.
Edit: Forgot to mention, I do have the monaco-editor loader up a bit higher in it's own <script> tag.
<script src="../node_modules/monaco-editor/min/vs/loader.js"></script>
I stepped away from this project for awhile, still haven't been able to quite figure it out.
Today I started a blank project with npm init, copy/pasted the example code for index.html from the README, did the index.js like it's shown on the Electron quick start guides (aside from enabling nodeIntegration and worldSafeJavaScript) and that is it, no more changes. Then I did npm install --save-dev electron and moved on.
At first, I thought it was working. I could run npm start and it opened up and worked as expected, no errors in the console. So I slowly started adding in things, changing editor settings, adding a stylesheet, testing in between each addition just in case. Everything was fine.
Until it wasn't, the error came back. I reloaded and it was gone again. Reloaded a few more times and sometimes it's there, and sometimes the console log is empty like everything is fine. Keep in mind at this point I haven't changed the index.html to remove the unkpg.com stuff to replace it with ../node_modules/, but I did try that next, and have the same results.
Something weird is happening and I have NO CLUE what it is. There's no example package.json on this repo that I found, but mine is extremely barebones, the only things I added really was the dependencies for monaco-editor and monaco-vim.
New discovery: Everything works perfectly fine when using the unpkg.com link to require, but not when using the npm version. That should maybe be fixed! @brijeshb42 (unless I'm doing something wrong still that causes this?)
@leftbones
Did you ever find a definitive solution? Neither unpkg.com nor having a local installation solved the missing import bug for me.