asciidoctor / asciidoctor-vscode

AsciiDoc support for Visual Studio Code using Asciidoctor
Other
328 stars 97 forks source link

Asciidoctor extensions don't work on Windows (cannot find module) #629

Closed edxu96 closed 2 years ago

edxu96 commented 2 years ago

Thanks for the effort. I'm trying to use an Asciidoctor.js extension (like asciidoctor-emoji), but it says the module cannot be found.

Description

The version of asciidoctor-vscode is 3.0.1.

It might be because I use nvm for the workspace.

System Information

Version: 1.71.0 (user setup)
Commit: 784b0177c56c607789f9638da7b6bf3230d47a8c
Date: 2022-09-01T07:36:10.600Z
Electron: 19.0.12
Chromium: 102.0.5005.167
Node.js: 16.14.2
V8: 10.2.154.15-electron.0
OS: Windows_NT x64 10.0.19043
Sandboxed: No

To Reproduce

Steps to reproduce the issue:

  1. Go to '...'
  2. Click on '....'
  3. Etc...

My settings are:

{
    "asciidoc.preview.useEditorStyle": false,
    "asciidoc.preview.scrollEditorWithPreview": false,
    "asciidoc.preview.scrollPreviewWithEditor": false,
    "asciidoc.preview.refreshInterval": 0,
    "asciidoc.preview.doubleClickToSwitchToEditor": false,
    "asciidoc.extensions.registerWorkspaceExtensions": true,
}

The error message is:

/c:/Users/xxx/GitHub/docs/.asciidoctor/lib/emoji.js: Error: Cannot find module '/c:/Users/xxx/GitHub/docs/.asciidoctor/lib/emoji.js' Require stack: - c:\Users\xxx\.vscode\extensions\asciidoctor.asciidoctor-vscode-3.0.1\dist\src\asciidocParser.js - c:\Users\xxx\.vscode\extensions\asciidoctor.asciidoctor-vscode-3.0.1\dist\src\image-paste.js - c:\Users\xxx\.vscode\extensions\asciidoctor.asciidoctor-vscode-3.0.1\dist\src\commands\pasteImage.js - c:\Users\xxx\.vscode\extensions\asciidoctor.asciidoctor-vscode-3.0.1\dist\src\commands\index.js - c:\Users\xxx\.vscode\extensions\asciidoctor.asciidoctor-vscode-3.0.1\dist\src\extension.js - c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\out\vs\loader.js - c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-amd.js - c:\Users\xxx\AppData\Local\Programs\Microsoft VS Code\resources\app\out\bootstrap-fork.js
qwertysk commented 2 years ago

I have the same problem :(

ggrossetie commented 2 years ago

@qwertysk could you please provide your system information? Are you also using Windows?

I don't think it's related to nvm because the file is required by the Node engine included in VS Code.

It might be related to the file path.

ggrossetie commented 2 years ago

@edxu96 does your path contains spaces or any specials characters?

ggrossetie commented 2 years ago

I can reproduce it and the fix is quite trivial 😄

qwertysk commented 2 years ago

Sorry I am late. I am also using Windows and my path does not contains spaces nor special characters. Regards.

edxu96 commented 2 years ago

does your path contains spaces or any specials characters?

@Mogztter No. Sorry, I'm late.

BTW, to build from source doesn't work in Windows. Furthermore, in order to see if you have resolved, I tried to build in WSL. I can install the resulted vsix in Windows, but the extension cannot be used. The error message is command 'asciidoc.showPreviewToSide' not found.

qwertysk commented 2 years ago

@edxu96 try this workaround:

image

ggrossetie commented 2 years ago

@edxu96 Could you please join the community chat to share what exactly did not work when you tried to build from source in Windows? https://chat.asciidoctor.org/

Furthermore, in order to see if you have resolved, I tried to build in WSL. I can install the resulted vsix in Windows, but the extension cannot be used. The error message is command 'asciidoc.showPreviewToSide' not found.

Indeed, I can reproduce this issue! The dependency js-yaml was incorrectly declared as a development dependency that's why the extension is not working properly:

[2022-09-07 12:10:25.190] [exthost] [error] Error: Cannot find module 'js-yaml'
Require stack:
- /home/guillaume/.vscode/extensions/asciidoctor.asciidoctor-vscode-3.0.1-dev/dist/src/features/antora/antoraSupport.js
- /home/guillaume/.vscode/extensions/asciidoctor.asciidoctor-vscode-3.0.1-dev/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 Module._resolveFilename (node:internal/modules/cjs/loader:987:15)
    at Module._load (node:internal/modules/cjs/loader:832:27)

As mentioned by @qwertysk since the fix is a one-liner you can modify the installed extension directly. Having said that we should definitely fix the build.

edxu96 commented 2 years ago

@edxu96 try this workaround:

image

@qwertysk Thanks for the tip. I have tried several times, but it doesn't work in my case. Probably because I have messed up with that part.

As @Mogztter suggested, I have continuted my question to zulipchat.

roseswe commented 10 months ago

Same issue here with MS Code 1.84 under Linux and "AsciiDoc 3.1.7" extension. Long ago this worked.

ggrossetie commented 10 months ago

@roseswe please open a new issue with a reproduction case