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

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

Closed
jiedxu opened this issue Sep 2, 2022 · 11 comments · Fixed by #630
Closed

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

jiedxu opened this issue Sep 2, 2022 · 11 comments · Fixed by #630
Labels
🐞 bug ⬜ windows Issues related to Microsoft's Windows

Comments

@jiedxu
Copy link

jiedxu commented Sep 2, 2022

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
Copy link

qwertysk commented Sep 2, 2022

I have the same problem :(

@ggrossetie
Copy link
Member

@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
Copy link
Member

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

@ggrossetie
Copy link
Member

I can reproduce it and the fix is quite trivial 😄

@ggrossetie ggrossetie changed the title To use Asciidoctor.js extension cannot find module Asciidoctor extensions does not work on Windows (cannot find module) Sep 4, 2022
@ggrossetie ggrossetie changed the title Asciidoctor extensions does not work on Windows (cannot find module) Asciidoctor extensions don't work on Windows (cannot find module) Sep 4, 2022
@ggrossetie ggrossetie added 🐞 bug ⬜ windows Issues related to Microsoft's Windows labels Sep 4, 2022
@qwertysk
Copy link

qwertysk commented Sep 5, 2022

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

@jiedxu
Copy link
Author

jiedxu commented Sep 6, 2022

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
Copy link

qwertysk commented Sep 6, 2022

@edxu96 try this workaround:

image

@ggrossetie
Copy link
Member

@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.

@jiedxu
Copy link
Author

jiedxu commented Sep 7, 2022

@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
Copy link

roseswe commented Nov 10, 2023

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

@ggrossetie
Copy link
Member

@roseswe please open a new issue with a reproduction case

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
🐞 bug ⬜ windows Issues related to Microsoft's Windows
Projects
None yet
4 participants