Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extension fails to load #325

Closed
3 of 11 tasks
thrust15 opened this issue May 11, 2020 · 9 comments
Closed
3 of 11 tasks

Extension fails to load #325

thrust15 opened this issue May 11, 2020 · 9 comments
Labels
bug Something isn't working

Comments

@thrust15
Copy link

thrust15 commented May 11, 2020

Hi,

I just installed the linuxserver/code-server docker container and installed your extension, however it didn't work for me. The only hint what I could find is the below snippet from exthost.log. I have no idea how to continue

[2020-05-11 23:28:18.431] [exthost] [info] ExtensionService#_doActivateExtension keesschollaart.vscode-home-assistant {"startup":true,"extensionId":{"value":"keesschollaart.vscode-home-assistant","_lower":"keesschollaart.vscode-home-assistant"},"activationEvent":"workspaceContains:**/configuration.yaml,**/ui-lovelace.yaml"}
[2020-05-11 23:28:18.431] [exthost] [info] ExtensionService#loadCommonJSModule file:///config/extensions/keesschollaart.vscode-home-assistant-1.6.5/out/extension
[2020-05-11 23:28:18.432] [exthost] [error] Activating extension keesschollaart.vscode-home-assistant failed due to an error:
[2020-05-11 23:28:18.433] [exthost] [error] Error: Cannot find module '/config/extensions/keesschollaart.vscode-home-assistant-1.6.5/out/extension'
Require stack:
- /app/code-server/lib/vscode/out/vs/loader.js
- /app/code-server/lib/vscode/out/bootstrap-amd.js
- /app/code-server/lib/vscode/out/bootstrap-fork.js
	at Function.Module._resolveFilename (internal/modules/cjs/loader.js:957:15)
	at Function.Module._load (internal/modules/cjs/loader.js:840:27)
	at Function.t._load (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:920:599)
	at Function.i._load (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:889:759)
	at Function.n._load (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:886:63)
	at Module.require (internal/modules/cjs/loader.js:1019:19)
	at require (internal/modules/cjs/helpers.js:77:18)
	at Function.s [as __$__nodeRequire] (/app/code-server/lib/vscode/out/vs/loader.js:32:963)
	at p._loadCommonJSModule (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:890:966)
	at p._doActivateExtension (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:788:856)
	at p._activateExtension (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:787:937)
	at Object.actualActivateExtension (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:785:883)
	at e._activateExtension (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:566:859)
	at /app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:566:537
	at Array.map (<anonymous>)
	at e._activateExtensions (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:566:525)
	at e.activateById (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:564:310)
	at p._activateById (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:786:681)
	at p._activateIfGlobPatterns (/app/code-server/lib/vscode/out/vs/workbench/services/extensions/node/extensionHostProcess.js:792:456)
	at processTicksAndRejections (internal/process/task_queues.js:97:5)
	at async Promise.all (index 1)
	at async Promise.all (index 79)
[2020-05-11 23:28:18.433] [exthost] [info] eager extensions activated

Find my Home Assistant Configuration here:

Extension runs in:

  • VS Code for Desktop
  • Hassio Add-on
  • Visual Studio Online
  • Other: Linuxserver/code-server docker image

I'm running VS Code on:

  • Windows
  • Mac
  • Linux

I'm accessing my files:

  • From local disk
  • Via remote SSH
  • Smb
  • Other: Via mounted volume in docker container from host.

Edit: added my docker-compose.yaml

version: "2.1"
services:
  code-server:
    image: linuxserver/code-server
    container_name: code-server
    environment:
      - PUID=984
      - PGID=984
      - TZ=Europe/Amsterdam
      - PASSWORD=${PASSWORD}
      - SUDO_PASSWORD=${SUDO_PASSWORD}
    volumes:
      - /opt/codeserver:/config
      - /opt/hassio/homeassistant:/config/workspace
    ports:
      - 8543:8443
    restart: unless-stopped
@thrust15 thrust15 added the bug Something isn't working label May 11, 2020
@thrust15
Copy link
Author

The whole 'out' folder is not created in /config/extensions/keesschollaart.vscode-home-assistant-1.6.5/

@dfmckay
Copy link

dfmckay commented May 18, 2020

This is happening to me to. tried both linuxserver and codercom docker images on ubuntu 18.04. I know my settings are correct because I tested them on my computer's VS Code.

@rust84
Copy link

rust84 commented May 18, 2020

Install also failed for me with addon-vscode/code-server using the store. Same module not found error. However when I tried installing using VSCode on Windows it worked. In the end I copied the files to my home assistant directory manually which got it working.

@DesNZ
Copy link

DesNZ commented Jun 24, 2020

Had the same issue. I setup vscode on my linux desktop and that worked fine so I copied the extension folder on my desktop (~/.vscode/extensions/keesschollaart.vscode-home-assistant-1.6.5) to the extensions folder of the code-server config and restarted. Everything works as intended now.

@frenck
Copy link
Collaborator

frenck commented Jul 26, 2020

Did you guys use a clone of this repo? If so, that will not work (and cause those issues).

For code-server the current compatible version of this extension is 1.6.5, the latest has issues caused by the Home Assistant WebSocket library.

The latter we hope to fix asap

@pedrolamas
Copy link
Contributor

I'm seeing this issue even with version 1.6.5 on codercom/code-server docker container. I have a feeling this is some configuration issue on vscode, but haven't gotten to the bottom of it yet...

@pedrolamas
Copy link
Contributor

@frenck I'm getting the error you mentioned:

internal/modules/cjs/loader.js:1216
      throw new ERR_REQUIRE_ESM(filename, parentPath, packageJsonPath);
      ^

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: /home/coder/.local/share/code-server/extensions/keesschollaart.vscode-home-assistant-1.8.0/node_modules/home-assistant-js-websocket/dist/haws.umd.js
require() of ES modules is not supported.
require() of /home/coder/.local/share/code-server/extensions/keesschollaart.vscode-home-assistant-1.8.0/node_modules/home-assistant-js-websocket/dist/haws.umd.js from /home/coder/.local/share/code-server/extensions/keesschollaart.vscode-home-assistant-1.8.0/out/language-service/src/home-assistant/haConnection.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files in that package scope as ES modules.
Instead rename haws.umd.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from /home/coder/.local/share/code-server/extensions/keesschollaart.vscode-home-assistant-1.8.0/node_modules/home-assistant-js-websocket/package.json.

    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1216:13)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14)
    at Module.require (internal/modules/cjs/loader.js:1089:19)
    at require (internal/modules/cjs/helpers.js:73:18)
    at Object.<anonymous> (/home/coder/.local/share/code-server/extensions/keesschollaart.vscode-home-assistant-1.8.0/out/language-service/src/home-assistant/haConnection.js:26:25)
    at Module._compile (internal/modules/cjs/loader.js:1200:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1220:10)
    at Module.load (internal/modules/cjs/loader.js:1049:32)
    at Function.Module._load (internal/modules/cjs/loader.js:937:14) {
  code: 'ERR_REQUIRE_ESM'
}
[Info  - 1:27:34 PM] Connection to server got closed. Server will restart.

By no means I'm any expert on JS stuff, but looking at the code here I would recommend replacing the output from AMD to ESM (I believe you can even have both, though most developers I know use CJS + ESM)

@frenck
Copy link
Collaborator

frenck commented Jul 27, 2020

Yes I am aware of the issue and the upstream PR, hence the additional note in the 1.8.0 release notes of this extension

Recent code-servers are bundled with NodeJS 14, which trigger the problem on code-server.

@frenck
Copy link
Collaborator

frenck commented Jul 27, 2020

fixed in #431

@frenck frenck closed this as completed Jul 27, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

6 participants