vuepress-reco / vuepress-theme-reco

🎨 This is the repo for vuepress-theme-reco 2.
https://vuepress-theme-reco.recoluan.com
MIT License
539 stars 175 forks source link

Must use import to load ES Module: @vuepress\plugin-back-to-top #127

Closed shichaohui closed 1 year ago

shichaohui commented 1 year ago

Bug report

Must use import to load ES Module: @vuepress\plugin-back-to-top

What is actually happening?

Error [ERR_REQUIRE_ESM]: Must use import to load ES Module: D:\GitHub\shichaohui\blog\node_modules\@vuepress\plugin-back-to-top\lib\node\index.js
require() of ES modules is not supported.
require() of D:\GitHub\shichaohui\blog\node_modules\@vuepress\plugin-back-to-top\lib\node\index.js from D:\GitHub\shichaohui\blog\node_modules\vuepress-theme-reco\lib\node\recoTheme.js is an ES module file as it is a .js file whose nearest parent package.json contains "type": "module" which defines all .js files 
in that package scope as ES modules.
Instead rename index.js to end in .cjs, change the requiring code to use import(), or remove "type": "module" from D:\GitHub\shichaohui\blog\node_modules\@vuepress\plugin-back-to-top\package.json.

    at new NodeError (internal/errors.js:322:7)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1102:13)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:12)
    at Module.require (internal/modules/cjs/loader.js:974:19)
    at require (internal/modules/cjs/helpers.js:93:18)
    at Object.<anonymous> (D:\GitHub\shichaohui\blog\node_modules\vuepress-theme-reco\lib\node\recoTheme.js:5:30)
    at Module._compile (internal/modules/cjs/loader.js:1085:14)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)

Other relevant information

senmu-a commented 1 year ago

So, what is your trouble?

Amoyens1s commented 1 year ago

@senmu-a 我和 @shichaohui 遇到的错误一样,换成recoTheme后项目无法启动 image

kongchengji commented 1 year ago

可能与@vuepress/plugin-back-to-top版本有关,我使用的是

image

recoluan commented 1 year ago

升级到最新版本 vuepress@2.0.0-beta.51 vuepress-theme-reco@2.0.0-beta.41,把 lock 文件和缓存文件删掉,试一下呢

shichaohui commented 1 year ago

升级后可以了 vuepress@2.0.0-beta.51 vuepress-theme-reco@2.0.0-beta.41