starter icon indicating copy to clipboard operation
starter copied to clipboard

Module starter not working

Open onmax opened this issue 8 months ago • 7 comments

  1. Go to nuxt.new
  2. Create a new nuxt-module using the starter -> codesandbox or stackblitz
  3. Run npm i && npm dev:prepare
  4. See error in the in the following details:
stackblitz error

Image

codesandbox error

Image


Solution

I lack of knowledge to know the reason why it fails, but it seems the problem is with addPlugin(resolver.resolve('./runtime/plugin'));

https://stackblitz.com/edit/github-fefin6wf?file=tsconfig.json


Let me know if I am doing something wrong!

onmax avatar May 07 '25 10:05 onmax

the error seems to be cause by not running npm run dev:prepare. are you sure you ran it?

danielroe avatar May 08 '25 09:05 danielroe

Sorry for the mix-up, I was testing other things and didn't reproduce the problem correctly.

If you open the project directly from StackBlitz it will run automatically:

npm install && npm run dev

and then displays an error. StackBlitz installs dependencies and runs dev for you (See docs.), but it doesn't do the dev:prepare step that dev requires. This can be confusing for someone new to this setup.

What do you think adding postinstall: "npm run dev:prepare" script?

onmax avatar May 08 '25 10:05 onmax

the problem is that the postinstall command would then run when users installed the module

danielroe avatar May 08 '25 10:05 danielroe

I didn't know postinstall also happens in node_modules.

Then, I don't think of any workaround. Feel free to close this issue if we don't come up with a better DX 😸

onmax avatar May 08 '25 13:05 onmax

we could add it to the dev command instead? "dev": "npm run dev:prepare && nuxi dev playground"

danielroe avatar May 08 '25 14:05 danielroe

Sure! If I do a PR, it will be automatically updated in the codesandbox and stackblitz, right?

onmax avatar May 08 '25 15:05 onmax

yes 👍

danielroe avatar May 08 '25 15:05 danielroe