Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

not work with nuxt 3.7 (Could not resolve import "micromark/lib/postprocess.js") #2254

Closed
Jannchie opened this issue Aug 26, 2023 · 18 comments
Closed
Labels
bug Something isn't working

Comments

@Jannchie
Copy link
Contributor

Environment

Operating System: Windows_NT
Node Version: v16.20.0
Nuxt Version: 3.7.0
CLI Version: 3.7.0
Nitro Version: 2.6.1
Package Manager: [email protected]
Builder: -
User Config: modules
Runtime Modules: @nuxt/[email protected]
Build Modules: -

Reproduction

npx nuxi@latest init content-app -t content

Describe the bug

It seems that content is currently completely incompatible with nuxt 3.7.

Additional context

No response

Logs

#  % Jannchie @ JANNCHIE-DESKTOP in D:\code [21:40:31]
$ npx nuxi@latest init content-app -t content
Need to install the following packages:
  [email protected]
Ok to proceed? (y) y

✔ Which package manager would you like to use?
pnpm
◐ Installing dependencies...                                                                                  21:40:40
Packages: +721
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Packages are hard linked from the content-addressable store to the virtual store.
  Content-addressable store is at: D:\.pnpm-store\v3
  Virtual store is at:             node_modules/.pnpm
Progress: resolved 775, reused 721, downloaded 0, added 721, done

devDependencies:
+ @nuxt/content 2.7.2
+ nuxt 3.7.0

Done in 15.9s
✔ Installation completed.                                                                                    21:40:56
                                                                                                              21:40:56
✨ Nuxt project has been created with the content template. Next steps:
 › cd content-app                                                                                             21:40:56
 › Start development server with pnpm run dev                                                                 21:40:56
(base)
#  % Jannchie @ JANNCHIE-DESKTOP in D:\code [21:40:56]
$ cd .\content-app\
(base)
#  % Jannchie @ JANNCHIE-DESKTOP in D:\code\content-app [21:41:01]
$ pnpm run dev

> @ dev D:\code\content-app
> nuxt dev

Nuxt 3.7.0 with Nitro 2.6.1                                                                                   21:41:04
                                                                                                              21:41:05
  ➜ Local:    http://localhost:3000/
  ➜ Network:  use --host to expose

ℹ Vite client warmed up in 972ms                                                                             21:41:08

[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/postprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/preprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/postprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/preprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/postprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/preprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/preprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/postprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/preprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  "micromark/lib/preprocess.js" is imported by "node_modules/.pnpm/@[email protected]/node_modules/@nuxt/content/dist/runtime/transformers/csv/from-csv.mjs", but could not be resolved – treating it as an external dependency.


[21:41:09]  WARN  (node-resolve plugin) Could not resolve import "micromark/lib/postprocess.js" in D:\Code\content-app\node_modules\.pnpm\@[email protected]\node_modules\@nuxt\content\dist\runtime\transformers\csv\from-csv.mjs using exports defined in D:\Code\content-app\node_modules\.pnpm\m[email protected]\node_modules\micromark\package.json.


[21:41:09]  WARN  "micromark/lib/postprocess.js" is imported by "node_modules/.pnpm/@[email protected]/node_modules/@nuxt/content/dist/runtime/transformers/csv/from-csv.mjs", but could not be resolved – treating it as an external dependency.

✔ Nitro built in 1460 ms                                                                               nitro 21:41:10

[21:41:10]  ERROR  [worker reload] [worker init] Package subpath './lib/preprocess.js' is not defined by "exports" in D:\Code\content-app\node_modules\micromark\package.json imported from D:\Code\content-app\.nuxt\dev\index.mjs

  at __node_internal_captureLargerStackTrace (node:internal/errors:478:5)
  at new NodeError (node:internal/errors:387:5)
  at throwExportsNotFound (node:internal/modules/esm/resolve:365:9)
  at packageExportsResolve (node:internal/modules/esm/resolve:649:3)
  at packageResolve (node:internal/modules/esm/resolve:833:14)
  at moduleResolve (node:internal/modules/esm/resolve:901:20)
  at defaultResolve (node:internal/modules/esm/resolve:1115:11)
  at nextResolve (node:internal/modules/esm/loader:163:28)
  at ESMLoader.resolve (node:internal/modules/esm/loader:841:30)
  at ESMLoader.getModuleJob (node:internal/modules/esm/loader:424:18)
  at ModuleWrap.<anonymous> (node:internal/modules/esm/module_job:76:40)
  at link (node:internal/modules/esm/module_job:75:36)
@nobkd
Copy link
Contributor

nobkd commented Aug 26, 2023

#2253 might fix that... Not sure though.

@zyhnbyyds

This comment was marked as duplicate.

@xarthurx

This comment was marked as duplicate.

1 similar comment
@renewii

This comment was marked as duplicate.

@pi0
Copy link
Member

pi0 commented Aug 26, 2023

As a temporary workaround, you can add this to your nuxt.config file:

export default defineNuxtConfig({
  alias: {
    "micromark/lib/preprocess.js": "micromark",
    "micromark/lib/postprocess.js": "micromark",
  },
});

Issue will hopefully be resolved with #2255

@pi0 pi0 changed the title Not work with nuxt 3.7 not work with nuxt 3.7 (Could not resolve import "micromark/lib/postprocess.js") Aug 26, 2023
@pi0 pi0 added the bug Something isn't working label Aug 26, 2023
@farnabaz
Copy link
Member

farnabaz commented Aug 27, 2023

The fix is released on the edge channel.
Do you mind trying the edge channel to confirm the fix?

Update: fix link

@Benbinbin
Copy link
Contributor

The fix is released on the edge channel. Do you mind trying the edge channel to confirm the fix?

the edge channel link is broken, try this link https://content.nuxtjs.org/guide/migration/edge-channel

@zyhnbyyds
Copy link

Thanks for your job. Now I use edge channel. It's normal🫡🫡🫡

@veritymedia
Copy link

I had the same issue. Using the edge channel fixed it. However, a new (similar) issue popped up. Cannot find module '[path]/.nuxt/dev/highlighter.mjs' imported from [path]/.nuxt/dev/index.mjs

:(

@farnabaz
Copy link
Member

@veritymedia did you try to remove lock file and re-install deps?

@veritymedia
Copy link

@farnabaz Yes, I did. But I have a feeling that the issue may be somehow tied to the fact that I'm using pnpm with workspaces. I've bashed my head on that particular wall too many times before.

@jwafu
Copy link

jwafu commented Aug 28, 2023

@farnabaz @veritymedia also have deleted and reinstalled deps - but not able to run dev environment to get anything to build locally. Using pnpm as well so curious to see what other information either of you have around this - if any updates

@veritymedia
Copy link

@jordan-pieces I noticed that my nuxt version was 3.0.0 so upgraded manually to 3.7.0. Deleted package-lock for good measure, and now the error is gone. Including nuxt/content in nuxt modules no longer crashes the app

@xarthurx
Copy link

Is it that before v2.7.3 is released, the fix only exists on the Edge channel?

@AdiRishi
Copy link

Hey all, just wanted to add some new details here.

alias: {
"micromark/lib/preprocess.js": "micromark",
"micromark/lib/postprocess.js": "micromark",
}

I used the above workaround provided in this thread and it works for the regular node build preset. However, when you run the nuxt build with a different preset, e.g cloudflare-pages there is another error.

Build command - NITRO_PRESET=cloudflare_pages yarn build

✔ Server built in 1853ms                                                                                                                                                  8:39:23 pm
✔ Generated public dist                                                                                                                                             nitro 8:39:24 pm
ℹ Initializing prerenderer                                                                                                                                          nitro 8:39:24 pm
ℹ Prerendering 1 routes                                                                                                                                             nitro 8:39:25 pm
  ├─ /api/_content/cache.1693305557145.json (310ms)                                                                                                                  nitro 8:39:26 pm
ℹ Building Nitro Server (preset: cloudflare_pages)                                                                                                                  nitro 8:39:26 pm

[nitro 8:39:32 pm]  ERROR  RollupError: "postprocess" is not exported by "../../node_modules/mdast-util-from-markdown/node_modules/micromark/index.js", imported by "../../node_modules/mdast-util-from-markdown/lib/index.js".


148: import {parse} from 'micromark/lib/parse.js'
149: import {preprocess} from 'micromark/lib/preprocess.js'
150: import {postprocess} from 'micromark/lib/postprocess.js'
             ^
151: import {decodeNumericCharacterReference} from 'micromark-util-decode-numeric-character-reference'
152: import {decodeString} from 'micromark-util-decode-string'


[8:39:32 pm]  ERROR  "postprocess" is not exported by "../../node_modules/mdast-util-from-markdown/node_modules/micromark/index.js", imported by "../../node_modules/mdast-util-from-markdown/lib/index.js".

  at error (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:2287:30)
  at Module.error (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:13716:16)
  at Module.traceVariable (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:14146:29)
  at ModuleScope.findVariable (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:12589:39)
  at FunctionScope.findVariable (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
  at ChildScope.findVariable (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:7124:38)
  at Identifier.bind (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:8309:40)
  at CallExpression.bind (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:5892:23)
  at CallExpression.bind (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:9875:15)
  at CallExpression.bind (/PATH_TO_REPO/node_modules/rollup/dist/es/shared/node-entry.js:5888:28)



[8:39:32 pm]  ERROR  "postprocess" is not exported by "../../node_modules/mdast-util-from-markdown/node_modules/micromark/index.js", imported by "../../node_modules/mdast-util-from-markdown/lib/index.js".

Wanted to add this in case it wasn't considered in the upcoming fix. Hope this helps 😄

@brawaru
Copy link

brawaru commented Aug 29, 2023

@AdiRishi seems like Nitro doesn't respect aliases, which is unfortunate. With pnpm you can at least override the version of micromark to 3.2.0, which fixes this. Perhaps something similar exist in Yarn?

  "pnpm": {
    "overrides": {
      "micromark": "3.2.0"
    }
  }

Copy link
Member

Did you tried to use edge-channel?

@farnabaz
Copy link
Member

The fix is released in v2.8.0.

sethidden added a commit to vuestorefront/vue-storefront that referenced this issue Sep 11, 2023
sethidden added a commit to vuestorefront/vue-storefront that referenced this issue Sep 12, 2023
* IN-362 Add package.json

* Mitigate IN-3641

See nuxt/content#2254 (comment)

* copy vuestorefront/sdk docs/new branch docs into here

* fix broken link

* remove unused images

* most headers use just "thing" not "Vue Storefront thing"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.