Vue2 模板編譯器壞了?
P粉731977554
P粉731977554 2024-02-26 14:13:23
0
1
452

我透過 webpack(^5.51.1) 和 vue-loader(^17.0.0) 編譯我的程式碼,我嘗試啟動一個舊項目,但它給了我這個錯誤:

[webpack-cli] Failed to load '/var/www/webpack.config.js' config
[webpack-cli] Error: Cannot find module 'vue/compiler-sfc'
Require stack:
- /var/www/node_modules/vue-loader/dist/resolveScript.js
- /var/www/node_modules/vue-loader/dist/select.js
- /var/www/node_modules/vue-loader/dist/index.js
- /var/www/webpack.config.js
- /var/www/node_modules/webpack-cli/lib/webpack-cli.js
- /var/www/node_modules/webpack-cli/lib/bootstrap.js
- /var/www/node_modules/webpack-cli/bin/cli.js
- /var/www/node_modules/webpack/bin/webpack.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:999:19)
    at require (/var/www/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at Object.<anonymous> (/var/www/node_modules/vue-loader/dist/resolveScript.js:5:24)
    at Module._compile (/var/www/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (node:internal/modules/cjs/loader:1151:10)
    at Module.load (node:internal/modules/cjs/loader:975:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
    at Module.require (node:internal/modules/cjs/loader:999:19) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/var/www/node_modules/vue-loader/dist/resolveScript.js',
    '/var/www/node_modules/vue-loader/dist/select.js',
    '/var/www/node_modules/vue-loader/dist/index.js',
    '/var/www/webpack.config.js',
    '/var/www/node_modules/webpack-cli/lib/webpack-cli.js',
    '/var/www/node_modules/webpack-cli/lib/bootstrap.js',
    '/var/www/node_modules/webpack-cli/bin/cli.js',
    '/var/www/node_modules/webpack/bin/webpack.js'
  ]
}

我真的不知道發生了什麼事。我嘗試將 @vue/compiler-sfc 新增到我的 package.json 但它不起作用。我真的不想切換到 Vue3,因為那會破壞很多東西。

編輯:請參閱 package.json:pastebin

P粉731977554
P粉731977554

全部回覆(1)
P粉486743671

似乎 vue-loader > 15 中有一些重大變化。它告訴我曾經強制 npm 保留在版本 15 上。在其他地方沒有找到...

熱門教學
更多>
最新下載
更多>
網站特效
網站源碼
網站素材
前端模板