我使用具有 monorepo 結構的 Next.js v13。當我嘗試在另一個 scss 檔案中匯入一個 scss 檔案時,我收到此錯誤:
ModuleParseError: Module parse failed: Unexpected character '@' (1:0)
You may need an appropriate loader to handle this file type, currently no loaders are configured to process this file. See https://webpack.js.org/concepts#loaders
> @import "~@shared/styles/variables.module.scss";
這是 next.config.js:
/** @type {import('next').NextConfig} */
const { dependencies } = require("./package.json");
const transpilePackages = Object.keys(dependencies || []).filter((dependency) =>
dependency.startsWith("@my-root-project/")
);
const nextConfig = {
experimental: {
appDir: true,
transpilePackages,
},
};
module.exports = nextConfig;
這是我的專案結構:
my-monorepo-folder:
- packages:
- apps:
- nextjs-website // (v13)
- package-1
- package-2
- shared
- styles
- variables.module.scss
我該如何處理這個錯誤?
uj5u.com熱心網友回復:
所以這是一個錯誤NextJs v13.0.0。升級版本后,此問題已解決。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qiye/527544.html
