RobertCraigie / pyright-python

Python command line wrapper for pyright, a static type checker
https://pypi.org/project/pyright/
MIT License
164 stars 22 forks source link

Cannot find module 'node:util' #254

Closed gmankab closed 6 months ago

gmankab commented 6 months ago
internal/modules/cjs/loader.js:775                                  
    throw err;                                                      
    ^                                                               
Error: Cannot find module 'node:util'                               
Require stack:                                                      
-                                                                   
C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\no             
de_modules\pyright\dist\pyright.js                                  
-                                                                   
C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\no             
de_modules\pyright\index.js                                         
    at Function.Module._resolveFilename                             
(internal/modules/cjs/loader.js:772:15)                             
    at Function.Module._load                                        
(internal/modules/cjs/loader.js:677:27)                             
    at Module.require                                               
(internal/modules/cjs/loader.js:830:19)                             
    at require (internal/modules/cjs/helpers.js:68:18)              
    at Object.9632                                                  
(C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\n             
ode_modules\pyright\dist\pyright.js:1:610)                          
    at o                                                            
(C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\n             
ode_modules\pyright\dist\pyright.js:1:1243)                         
    at Object.1264                                                  
(C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\n             
ode_modules\pyright\dist\vendor.js:2:794958)                        
    at o                                                            
(C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\n             
ode_modules\pyright\dist\pyright.js:1:1243)                         
    at Object.1476                                                  
(C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\n             
ode_modules\pyright\dist\pyright-internal.js:1:441712)              
    at o                                                            
(C:\Users\gitlab_runner\.cache\pyright-python\1.1.353\n             
ode_modules\pyright\dist\pyright.js:1:1243) {                       
  code: 'MODULE_NOT_FOUND',                                         
  requireStack: [                                                   
    'C:\\Users\\gitlab_runner\\.cache\\pyright-python\\             
1.1.353\\node_modules\\pyright\\dist\\pyright.js',                  
    'C:\\Users\\gitlab_runner\\.cache\\pyright-python\\             
1.1.353\\node_modules\\pyright\\index.js'                           
  ]                                                                 
}                                                                   

i am getting this error on gitlab shared windows runner

on linux runner there is no such issue

also on github there is no issue on both windows and linux

benhoyt commented 6 months ago

I'm getting this same issue with version 1.1.352 and 1.1.352 (but not 1.1.351 and earlier versions). For example:

$ tox -e static
static: recreate env because requirements removed: pyright==1.1.352
static: remove tox env folder /home/ben/w/argo-rollouts-k8s-operator/.tox/static
static: install_deps> python -I -m pip install pyright==1.1.353 -r /home/ben/w/argo-rollouts-k8s-operator/requirements.txt
static: commands[0]> pyright
internal/modules/cjs/loader.js:818
  throw err;
  ^

Error: Cannot find module 'node:util'
Require stack:
- /home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright.js
- /home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/index.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:815:15)
    at Function.Module._load (internal/modules/cjs/loader.js:667:27)
    at Module.require (internal/modules/cjs/loader.js:887:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.9632 (/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright.js:1:610)
    at o (/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright.js:1:1243)
    at Object.1264 (/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/vendor.js:2:794958)
    at o (/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright.js:1:1243)
    at Object.1476 (/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright-internal.js:1:441712)
    at o (/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright.js:1:1243) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/dist/pyright.js',
    '/home/ben/.cache/pyright-python/1.1.353/node_modules/pyright/index.js'
  ]
}
static: exit 1 (0.30 seconds) /home/ben/w/argo-rollouts-k8s-operator> pyright pid=1627781
  static: FAIL code 1 (3.10=setup[2.80]+cmd[0.30] seconds)
  evaluation failed :( (3.13 seconds)

My Python version is 3.10.12.

erictraut commented 6 months ago

Which version of node do you have installed on your system? We recently bumped the minimum version from v12 to v14 (both of which are ancient at this point).

benhoyt commented 6 months ago

Ah yes, that would be it. node --version says I'm running v12.22.9. I'll upgrade. Might be nice if it's able to give a more helpful error message though.

gmankab commented 6 months ago
choco install nodejs --version=21 -y -f

this fixed issue, thanks

Might be nice if it's able to give a more helpful error message though

yes, it would be nice