thunderclient / thunder-client-support

Thunder Client is a lightweight Rest API Client Extension for VS Code.
https://www.thunderclient.com
Other
3.61k stars 126 forks source link

Chance npm library not functioning as described in documentation #1511

Closed ColinSowul closed 4 months ago

ColinSowul commented 5 months ago

Describe the bug Currently, when attempting to load Chance from npm, an error occurs when constructing the main object that offers Chance apis: Error in Pre Request Script: - Chance is not a constructor The code I'm using the create an Chance object matches the ThunderClient documentation

To Reproduce Add this code block to a Pre-Request script of a request and run it:

var Chance = await tc.loadModule("chance");
var chance = new Chance();

Expected behavior The main object from the chance library is instantiated and can be used

Platform:

Are you using the free version/paid version/trial: paid version

rangav commented 5 months ago

Hi @ColinSowul

I just tested the below code its working for me, can you please update the extension to v2.20.1 and try again

var Chance = await tc.loadModule("chance");
var chance = new Chance();
console.log("firstName", chance.name());
ColinSowul commented 5 months ago

Just updated my extension version to v2.20.1 but I'm still getting the error.

If it helps, I was also able to view more detailed logs in the console:

Script Log: Error loading node package: chance - Command failed: ..... c:\Users\Colin Sowul\.vscode\extensions\rangav.vscode-thunder-client-2.20.1\dist chance@latest
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Colin Sowul\AppData\Local\Programs\Microsoft VS Code\Sowul\.vscode\extensions\rangav.vscode-thunder-client-2.20.1\dist/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Colin Sowul\AppData\Local\Programs\Microsoft VS Code\Sowul\.vscode\extensions\rangav.vscode-thunder-client-2.20.1\dist\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 
rangav commented 5 months ago

Thanks for sharing logs will verify and get back to you.

rangav commented 5 months ago

We made few changes to fix this issue, Can you please install the new update vsix file manually and test it.

vscode-thunder-client-2.20.2.vsix.zip

ColinSowul commented 5 months ago

I installed that .vsix file but I'm still seeing the issue, with the same logs as well

I also tried updating the plugin to v2.20.3, but that isn't working either

rangav commented 5 months ago

Thanks for testing it. Will verify again and get back to you.

rangav commented 5 months ago

I have tested on windows 11 and windows 10 (with node 18.17.1) its working on both OS for me.

can you please restart your PC and test again?

May be it could be a permissions issue?

ColinSowul commented 5 months ago

I've restarted my PC and ran VSCode as an administrator, but I'm still experiencing this issue. Also reached out to my coworkers and they seem to still be having this issue as well

rangav commented 5 months ago

Thanks for the confirmation.

  1. As a temporary solution - please downgrade extension to v2.19.9.
  2. Another alternative solution - Please install the Chance node module manually in the extension installed path

Could we schedule a call for next week to investigate the issue?

Please contact us using the form below, providing your available dates and time slots https://www.thunderclient.com/contact

rangav commented 4 months ago

Hi Colin, I have fixed the issue, Can you please install the VSIX file manually and test it vscode-thunder-client-2.21.1.vsix.zip

ColinSowul commented 4 months ago

Still getting the same error with that version

rangav commented 4 months ago

Can you please share the logs again, the paths should be different now

rangav commented 4 months ago

I have also published new version of cli - v1.13.4

can you please install latest update using cmd - npm i -g @thunderclient/cli and test it.

ColinSowul commented 4 months ago

Just tried the cli, got an error with that as well.

Here are the log outputs for the VSCode plugin and the CLI: VSCode:

Script Log: Error loading node package: chance - Command failed:  Installing chance@latest
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Colin Sowul\AppData\Local\Programs\Microsoft VS Code\Sowul\.vscode\extensions\rangav.vscode-thunder-client-2.21.1\dist/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Colin Sowul\AppData\Local\Programs\Microsoft VS Code\Sowul\.vscode\extensions\rangav.vscode-thunder-client-2.21.1\dist\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in: C:\Users\Colin Sowul\AppData\Local\npm-cache\_logs\2024-04-15T18_43_48_211Z-debug-0.log

Error in Script: - Chance is not a constructor 

CLI:

Script Log: Error loading node package: chance - Command failed:  Installing chance@latest
npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path C:\Users\Colin Sowul\Documents\git\allo-fiber-thunder-client\Sowul\AppData\Roaming\npm\node_modules\thunderclient-cli\dist/package.json
npm ERR! errno -4058
npm ERR! enoent ENOENT: no such file or directory, open 'C:\Users\Colin Sowul\Documents\git\allo-fiber-thunder-client\Sowul\AppData\Roaming\npm\node_modules\thunderclient-cli\dist\package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent

npm ERR! A complete log of this run can be found in: C:\Users\Colin Sowul\AppData\Local\npm-cache\_logs\2024-04-15T21_20_53_281Z-debug-0.log

Error in Script: - Chance is not a constructor
rangav commented 4 months ago

@ColinSowul I have made few more changes to fix this. Can you please test the v2.21.2 version below

vscode-thunder-client-2.21.2.vsix.zip

ColinSowul commented 4 months ago

That fixed it, my pre-request script & request are running successfully with that version

rangav commented 4 months ago

Finally, we fixed this. Thanks for the confirmation. I have published the update to the marketplace.