Skip to content

[labs/cli] First lit labs gen command requiring install always errors #3235

@augustjk

Description

@augustjk

Which package(s) are affected?

Other/unknown (please mention in description)

Description

First call of lit labs gen with a specific framework prompts to install the respective gen-wrapper-<framework> package but execution errors after install.

$ npx lit labs gen --framework=react
The command react is not installed.
Run 'npm install --save-dev @lit-labs/gen-wrapper-react'? [Y/n]
y

added 1 package, and audited 84 packages in 377ms


5 packages are looking for funding
  run `npm fund` for details


found 0 vulnerabilities

(node:42852) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/Users/augustinekim/testing/cli-test2/node_modules/@lit-labs/gen-wrapper-react/index.js:6
import * as path from 'path';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Object.compileFunction (node:vm:352:18)
    at wrapSafe (node:internal/modules/cjs/loader:1033:15)
    at Module._compile (node:internal/modules/cjs/loader:1069:27)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1159:10)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at ModuleWrap.<anonymous> (node:internal/modules/esm/translators:170:29)
    at ModuleJob.run (node:internal/modules/esm/module_job:198:25)
    at processTicksAndRejections (node:internal/process/task_queues:96:5)
    at async Promise.all (index 0)

Following this up with npx lit labs gen --framework=react immediately, the command executes properly.

It seems like the execution switches to cjs after npm installing causing the above error.

Reproduction

Command listed above.

Workaround

Need to execute the command again with the correct gen-wrapper-<framework> package installed.

Is this a regression?

No or unsure. This never worked, or I haven't tried before.

Affected versions

0.1.0

Browser/OS/Node environment

Node: 16.16.0

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    Status

    ✅ Done

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions