bowencool / create-vitepress-demo

基于 vitepress 扩展更专业的 Demo 演示能力的文档方案
https://bowencool.github.io/create-vitepress-demo/guide/contribution.html
54 stars 12 forks source link

Error: Cannot find module 'vitepress/dist/node/serve-9731a371.js' Require stack #1

Closed carlosal1015 closed 2 years ago

carlosal1015 commented 2 years ago

Hi, I have the following message error, including a screencast.

yarn run v1.22.17
$ check-versions && ([ -d es ] || npm run build) && patch-package
npm WARN lifecycle The node binary used for scripts is /tmp/yarn--1643473577005-0.5685516487652051/node but npm is using /home/carlosal1015/.nvm/versions/node/v14.16.0/bin/node itself. Use the `--scripts-prepend-node-path` option to include the path for the node binary npm was executed with.

> docs@0.1.0 prebuild /tmp/blog
> check-versions && rm -rf es cjs && patch-package

patch-package 6.4.7
Applying patches...

**ERROR** Failed to apply patch for package vitepress at path

    node_modules/vitepress

  This error was caused because vitepress has changed since you
  made the patch file for it. This introduced conflicts with your patch,
  just like a merge conflict in Git when separate incompatible changes are
  made to the same piece of code.

  Maybe this means your patch file is no longer necessary, in which case
  hooray! Just delete it!

  Otherwise, you need to generate a new patch file.

  To generate a new one, just repeat the steps you made to generate the first
  one.

  i.e. manually make the appropriate file changes, then run 

    patch-package vitepress

  Info:
    Patch file: patches/vitepress+0.21.4.patch
    Patch was made for version: 0.21.4
    Installed version: 0.21.6

---
patch-package finished with 1 error(s).

> docs@0.1.0 build /tmp/blog
> NODE_ENV=production rollup -c build/rollup.config.comps.js

/tmp/blog/packages/index.ts → es...                                                                                                                                       
created es in 2.9s

/tmp/blog/packages/index.ts → cjs...                                                                                                                                      
created cjs in 1.3s
patch-package 6.4.7
Applying patches...

**ERROR** Failed to apply patch for package vitepress at path

    node_modules/vitepress

  This error was caused because vitepress has changed since you
  made the patch file for it. This introduced conflicts with your patch,
  just like a merge conflict in Git when separate incompatible changes are
  made to the same piece of code.

  Maybe this means your patch file is no longer necessary, in which case
  hooray! Just delete it!

  Otherwise, you need to generate a new patch file.

  To generate a new one, just repeat the steps you made to generate the first
  one.

  i.e. manually make the appropriate file changes, then run 

    patch-package vitepress

  Info:
    Patch file: patches/vitepress+0.21.4.patch
    Patch was made for version: 0.21.4
    Installed version: 0.21.6

---
patch-package finished with 1 error(s).
$ NODE_ENV=development vitepress dev website
vitepress v0.21.6
failed to load config from /tmp/blog/website/.vitepress/config.js
failed to start server. error:
 Error: Cannot find module 'vitepress/dist/node/serve-9731a371.js'
Require stack:
- /tmp/blog/website/.vitepress/config.js
- /tmp/blog/node_modules/vite/dist/node/chunks/dep-f5552faa.js
- /tmp/blog/node_modules/vite/dist/node/index.js
- /tmp/blog/node_modules/vitepress/dist/node/serve-9874c5ac.js
- /tmp/blog/node_modules/vitepress/dist/node/cli.js
- /tmp/blog/node_modules/vitepress/bin/vitepress.js
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
    at Function.Module._load (internal/modules/cjs/loader.js:725:27)
    at Module.require (internal/modules/cjs/loader.js:952:19)
    at require (internal/modules/cjs/helpers.js:88:18)
    at website/.vitepress/markdown/plugin/markdown-it-demo.ts (/tmp/blog/website/.vitepress/config.js:164:40)
    at __init (/tmp/blog/website/.vitepress/config.js:9:50)
    at website/.vitepress/config.ts (/tmp/blog/website/.vitepress/config.js:210:5)
    at __init (/tmp/blog/website/.vitepress/config.js:9:50)
    at Object.<anonymous> (/tmp/blog/website/.vitepress/config.js:239:28)
    at Module._compile (internal/modules/cjs/loader.js:1063:30) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/tmp/blog/website/.vitepress/config.js',
    '/tmp/blog/node_modules/vite/dist/node/chunks/dep-f5552faa.js',
    '/tmp/blog/node_modules/vite/dist/node/index.js',
    '/tmp/blog/node_modules/vitepress/dist/node/serve-9874c5ac.js',
    '/tmp/blog/node_modules/vitepress/dist/node/cli.js',
    '/tmp/blog/node_modules/vitepress/bin/vitepress.js'
  ]
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
bowencool commented 2 years ago

I'll fix it in a few days, lock the version of vitepress first:

-    "vitepress": "^0.21.4",
+    "vitepress": "0.21.4",
bowencool commented 2 years ago

fixed in #4

carlosal1015 commented 2 years ago

Thanks @bowencool, I tested now and is working!