actions / languageservices

Language services for GitHub Actions workflows and expressions.
MIT License
74 stars 25 forks source link

expressions: ERR_MODULE_NOT_FOUND attempting to run example demo script #64

Open dekimsey opened 10 months ago

dekimsey commented 10 months ago

Describe the bug The instructions for running the demo don't seem to work. While I'm pretty sure it's user error, it's not clear how to address this. Especially from within the runtime context of a @actions/github-script.

To Reproduce Steps to reproduce the behavior:

  1. npm install @actions/expressions
  2. copy example code block, simple example to a file (note: it's not obvious, but it appears it must be in a mjs file as it uses imports keyword)
  3. run with: node ./example.mjs.

Expected behavior A testable example.

Screenshots

$ npm install @actions/expressions
$ vim example.mjs
...
$ node example.mjs
node:internal/modules/esm/resolve:264
    throw new ERR_MODULE_NOT_FOUND(
          ^

Error [ERR_MODULE_NOT_FOUND]: Cannot find module '/private/var/folders/j0/_6v6ffj54qs0wrl91bz5tbw40000gp/T/tmp.mvxT5dPk/node_modules/@actions/expressions/dist/ast' imported from /private/var/folders/j0/_6v6ffj54qs0wrl91bz5tbw40000gp/T/tmp.mvxT5dPk/node_modules/@actions/expressions/dist/index.js
    at finalizeResolution (node:internal/modules/esm/resolve:264:11)
    at moduleResolve (node:internal/modules/esm/resolve:917:10)
    at defaultResolve (node:internal/modules/esm/resolve:1130:11)
    at ModuleLoader.defaultResolve (node:internal/modules/esm/loader:396:12)
    at ModuleLoader.resolve (node:internal/modules/esm/loader:365:25)
    at ModuleLoader.getModuleJob (node:internal/modules/esm/loader:240:38)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:85:39)
    at link (node:internal/modules/esm/module_job:84:36) {
  code: 'ERR_MODULE_NOT_FOUND',
  url: 'file:///private/var/folders/j0/_6v6ffj54qs0wrl91bz5tbw40000gp/T/tmp.mvxT5dPk/node_modules/@actions/expressions/dist/ast'
}

Node.js v21.4.0

Package/Area

Package Version v0.3.8

Additional context

I really just want to access this module from within a @actions/github-script step but for the life of me I haven't been able to figure out how to do that. With other NPM installed modules it was some variation of an import directive. However, this one just doesn't work. So I tried just replicating exactly what is documented in this project to check my assumptions. Which is how I came to this point.

I'll be honest, this could very well be user error. Undoubtedly further complicated by my personal lack of familiarity with the state of module/script vs require/imports in Node. But struggle as I may, I cannot figure out how to import this module into a script to run.

Very likely related to #50.

Thank you