micro-dev icon indicating copy to clipboard operation
micro-dev copied to clipboard

micro-dev and .mjs "experimental-modules"

Open tylerthebuildor opened this issue 7 years ago • 2 comments

I'm trying to get micro-dev working with my .mjs files.

I tried the proposed solution in this closed issue but it throws an error and I'm unsure of a workaround.

"dev": "node --experimental-modules node_modules/.bin/micro-dev index.mjs"

Produces the following error:

micro: Error when importing
Error [ERR_REQUIRE_ESM]: Must use import to load ES Module

tylerthebuildor avatar Jul 10 '18 17:07 tylerthebuildor

I've been using micro-dev with the esm package just fine

  "scripts": {
    "start": "node -r esm ./node_modules/.bin/micro src/index.js",
    "dev": "node -r esm ./node_modules/.bin/micro-dev src/index.js"
  },
  "dependencies": {
    "micro": "^9.3.3",
    "esm": "^3.0.84"
  },
  "devDependencies": {
    "micro-dev": "^3.0.0"
  }

It's probably not as fast as built in experimental modules, but maybe it'll help you get where you need to be

DonnieWest avatar Sep 19 '18 00:09 DonnieWest

You can fix this after accepting PR to micro: https://github.com/vercel/micro/pull/448 or now with using npm i -D es-micro-dev

PonomareVlad avatar Nov 04 '21 20:11 PonomareVlad