Language-tools: Extension not working (only syntax highlighting that is working)

Created on 18 Oct 2020  路  13Comments  路  Source: sveltejs/language-tools

Describe the bug
Extension is unable to provide a proper autocomplete, it only provides a syntax highlighting,
all svelte commands like restart lang server is also failing even after custom path to lang server is set

To Reproduce
Install extension on vscode,
create a new project
navigate to App.svelte
try the autocomplete or the command such as restart lang server

Expected behavior
It should show proper autocomplete and formatting capabilites.

System (please complete the following information):

  • OS: Pop Os 20.04
  • IDE: VScode
  • Plugin/Package: Svelte for VSCode
bug

All 13 comments

Can you check the output channel at the bottom and choose svelte in the bottom right dropdown at see if there are any errors logged?

[2020-10-18 11:10:24.407] [exthost] [error] Activating extension svelte.svelte-vscode failed due to an error:
[2020-10-18 11:10:24.419] [exthost] [error] Error: Cannot find module 'semver'
Require stack:
- /home/ravel/.vscode/extensions/svelte.svelte-vscode-102.2.0/node_modules/vscode-languageclient/lib/main.js
- /home/ravel/.vscode/extensions/svelte.svelte-vscode-102.2.0/dist/src/extension.js
- /usr/share/code/resources/app/out/vs/loader.js
- /usr/share/code/resources/app/out/bootstrap-amd.js
- /usr/share/code/resources/app/out/bootstrap-fork.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:844:17)
    at Module._load (internal/modules/cjs/loader.js:737:27)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Function.t._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1057:776)
    at Function.i._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1027:486)
    at Function.n._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1023:767)
    at Module.require (internal/modules/cjs/loader.js:899:19)
    at r (/usr/share/code/resources/app/out/vs/loader.js:17:346)
    at Object.<anonymous> (/home/ravel/.vscode/extensions/svelte.svelte-vscode-102.2.0/node_modules/vscode-languageclient/lib/main.js:12:16)
    at Module.i._compile (/usr/share/code/resources/app/out/vs/loader.js:17:571)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1051:10)
    at Module.load (internal/modules/cjs/loader.js:862:32)
    at Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Function.t._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1057:776)
    at Function.i._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1027:486)
    at Function.n._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1023:767)
    at Module.require (internal/modules/cjs/loader.js:899:19)
    at r (/usr/share/code/resources/app/out/vs/loader.js:17:346)
    at Object.<anonymous> (/home/ravel/.vscode/extensions/svelte.svelte-vscode-102.2.0/dist/src/extension.js:27:33)
    at Module.i._compile (/usr/share/code/resources/app/out/vs/loader.js:17:571)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1051:10)
    at Module.load (internal/modules/cjs/loader.js:862:32)
    at Module._load (internal/modules/cjs/loader.js:774:14)
    at Function.Module._load (electron/js2c/asar.js:769:28)
    at Function.t._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1057:776)
    at Function.i._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1027:486)
    at Function.n._load (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1023:767)
    at Module.require (internal/modules/cjs/loader.js:899:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Function.s [as __$__nodeRequire] (/usr/share/code/resources/app/out/vs/loader.js:34:963)
    at p._loadCommonJSModule (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:1028:771)
    at p._doActivateExtension (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:925:742)
    at p._activateExtension (/usr/share/code/resources/app/out/vs/workbench/services/extensions/node/extensionHostProcess.js:924:822)
    at processTicksAndRejections (internal/process/task_queues.js:94:5)
    at async Promise.all (index 0)

Seems like some dependence is not installed. Don't know if that's a deploy issue or installation issue. Maybe you can try reinstall the extension.

Reinstalled and still no success

Very strange. I did a fresh install of the extension and cannot reproduce this. I looked into the VSIX of the extension and semver is in there. Could you look up the path where your extension is installed, look into the node_modules folder (essentially the one that's in your error message stack) and see if the semver is in there? Did it work with a previous extension version?

yup, for some reason semver is not there, here is the contents of the node_modules

chokidar     estree-walker  svelte-language-server
cosmiconfig  lodash         vscode-languageclient

Before this happen, the extension actually had worked properly, but i'm not sure if it's a previous version of the extension or the same version.

Very strange, that's definitely too few modules. If you revert to an older version, does the error persist? You can also try downloading the extension from the website and unpackaging it into the folder.

I've tried several different version and the result is still the same, i even try to reinstall vscode and still the problem presist.
i assume that the problem is specific to my machine,
so i'm switching to webstorm (there is no problem with svelte extension there)

Thanks for the help

Did you try manually downloading the VSIX bundle from the marketplace website and unpackage it into VSCode's extensions folder (ZIP is enough to unpack)?

I have the same problem, on the same system. Installing it from the marketplace through unpackaging it doesn't help. It's really weird because it stopped working when I switched to Pop OS from Manjaro - on which it was working perfectly fine.

The Svelte extension suffers from the same problem on my Windows machine in VS Code - no Svelte intellisense, and restarting the Svelte server just gives me "Command 'Svelte: Restart Language Server' resulted in an error (command 'svelte.restartLanguageServer' not found)".

VS Code: 1.52.1
Svelte extension: 104.1.0
Node version: 14.15.3

The problem seems to come from this line in the /dist/src/extension.js file:

    const lsPath = tempLsPath && tempLsPath.trim() !== ''
        ? path.isAbsolute(tempLsPath)
            ? tempLsPath
            : path.join(rootPath, tempLsPath)
        : undefined;
    const serverModule = require.resolve(lsPath || 'svelte-language-server/bin/server.js');

Which is producing bad paths to my node executable by concatenating the project directory with my node path environment variable. For example, it thinks "C:\Users\me\Documents\projects\projectA\C:\Program Files(x86)\nodejs\node.exe" is a valid path

My temporary resolution for this is to change the const serverModule line to

    const serverModule = require.resolve('svelte-language-server/bin/server.js');

Interesting, so it only occurs because you did set the ls-path. Why did you set that path if you now choose to ignore it? What did you set it to?

You're right, I did have modified values for my ls-path. I must have forgotten to undo them - I had encountered this same error, svelte not offering intellisense, a few months back and was fiddling around with those settings in hopes it would fix it. At the time, it didn't change anything, and I was left with a broken installation.

After you pointed that out, I went back and set the ls-path back to empty, restored the ls_path || to the server module line, restarted vs code and it worked fine.

While looking for a solution to this problem yesterday, I did notice on some other thread that I can't find at the moment that there was a requirement for a certain, fairly recent version of VS Code, I think for 1.48.x or higher. It's possible that when I first found the issue I was on a version of code that wasn't supported, but now I am.

Was this page helpful?
0 / 5 - 0 ratings