microsoft / inshellisense

IDE style command line auto complete
MIT License
8.24k stars 181 forks source link

Cannot find module when press ctrl+a to tigger completion #50

Closed techstay closed 7 months ago

techstay commented 8 months ago

Describe the bug The prompt failed to find its dependencies to launch. When I use Ctrl+A to trigger the completion, it raises such errors.

node:internal/modules/cjs/loader:1051
  throw err;
  ^                                                                                                                     
Error: Cannot find module 'C:\Users\asddf\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js'
    at Module._resolveFilename (node:internal/modules/cjs/loader:1048:15)
    at Module._load (node:internal/modules/cjs/loader:901:27)
    at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:83:12)
    at node:internal/main/run_main_module:23:47 {
  code: 'MODULE_NOT_FOUND',
  requireStack: []
}

Node.js v20.9.0

To Reproduce After installation, press ctrl+a and it raises the errors.

Expected behavior proper completion

Environment

Additional context I use scoop to install nodejs-lts package, so the installation path may differ from the normal installation.

❯ which npm
C:/Users/asddf/scoop/apps/nodejs-lts/current/bin/npm.cmd
❯ which inshellisense
C:/Users/asddf/scoop/apps/nodejs-lts/current/bin/inshellisense.cmd
cpendery commented 8 months ago

@techstay which shell is this in and you're still able to successfully run inshellisense --version? Can you try directly running inshellisense via inshellisense -s <shell>

zy97 commented 8 months ago

I have same problem,i'm using pwsh7.3.9 and windows powershell now. but inshellisense -s pwsh does working,inshellisense bind doesn't working. image image

BrightXiaoHan commented 8 months ago

same problem image

ilkerhalil commented 8 months ago

Same problem. image

techstay commented 8 months ago

@techstay which shell is this in and you're still able to successfully run inshellisense --version? Can you try directly running inshellisense via inshellisense -s <shell>

I use pwsh and running inshellisense -s ` works fine. Just like other guys here.

Devil-SX commented 8 months ago

Same problem. I use MSYS2-bash on Windows

image

anthea-wu commented 7 months ago

I solve this problems by below steps:

  1. open power shell and types npm config get prefix to check where npm install
  2. finding your key-bindings-powershell.ps1, replace $inshellisense to your npm install path

for example:

  1. original $inshellisense in key-bindings-powershell.ps1 is $env:USERPROFILE\AppData\Roaming\npm\node_modules\@microsoft\inshellisense\build\index.js
  2. my npm install in C:\Program Files\nodejs\node_modules
  3. change $inshellisense to c:\PROGRA~1\nodejs\node_modules\@microsoft\inshellisense\build\index.js

be aware of Program Files, it has a whitespace, so need to write to PROGRA~1.

hopes this answer helpful. (this answer is based on this pull request, but copy-paste not work for me, write npm config get prefix in .ps1 don't work)

Monarch510 commented 7 months ago

Same Problem【Solved】

image

Environment:

os: win10 node: v20.2.0 inshellisence: 0.0.1-rc.4

Solution:

https://github.com/microsoft/inshellisense/issues/50#issuecomment-1820566295 Refer to the above practice。

Here are a few things I added:

image Change file's content in this picture.

cpendery commented 7 months ago

Closing as the ctrl-a binding was removed in 0.0.1-rc.5