【发布时间】:2021-03-19 22:15:57
【问题描述】:
我正在静态生成使用 NextJS 中的组件的页面。我将 Bootstrap 和 SASS 与全局 styles.scss 一起使用。
当我尝试从我的 Github 存储库将我的应用程序部署到 Vercel 时,编译失败。该错误与 sass 相关,但我终其一生都无法弄清楚是什么原因造成的。在本地运行或构建时不存在任何错误。
部署时,错误提示它不能在我的全局 .scss 文件中使用 @import 文件。
我正在使用最新版本的 Next.js 9 >。
部署错误日志如下所示:-
21:36:21 Cloning github.com/nigeymc/Portfolio-App-NextJS-Refactor (Branch: master, Commit: baa537e)
21:36:22 Cloning completed in 418ms
21:36:22 Analyzing source code...
21:36:22 Installing build runtime...
21:36:25 Build runtime installed: 2976.247ms
21:36:28 Looking up build cache...
21:36:28 Build cache not found
21:36:29 Installing dependencies...
21:36:29 yarn install v1.22.10
21:36:29 [1/4] Resolving packages...
21:36:30 [2/4] Fetching packages...
21:37:07 info fsevents@2.3.2: The platform "linux" is incompatible with this module.
21:37:07 info "fsevents@2.3.2" is an optional dependency and failed compatibility check. Excluding it from installation.
21:37:07 info fsevents@1.2.13: The platform "linux" is incompatible with this module.
21:37:07 info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
21:37:07 [3/4] Linking dependencies...
21:37:07 warning " > bootstrap@4.6.0" has unmet peer dependency "popper.js@^1.16.1".
21:37:24 [4/4] Building fresh packages...
21:37:36 Done in 66.23s.
21:37:36 Detected Next.js version: 10.0.7
21:37:36 Running "yarn run build"
21:37:36 yarn run v1.22.10
21:37:36 $ next build
21:37:37 info - Creating an optimized production build...
21:37:37 Attention: Next.js now collects completely anonymous telemetry regarding usage.
21:37:37 This information is used to shape Next.js' roadmap and prioritize features.
21:37:37 You can learn more, including how to opt-out if you'd not like to participate in this anonymous program, by visiting the following URL:
21:37:37 https://nextjs.org/telemetry
21:37:59 Failed to compile.
21:37:59 ./styles/styles.scss
21:37:59 SassError: Can't find stylesheet to import.
21:37:59 ╷
21:37:59 2 │ @import "./variables/Colors";
21:37:59 │ ^^^^^^^^^^^^^^^^^^^^
21:37:59 ╵
21:37:59 styles/styles.scss 2:9 root stylesheet
21:37:59 > Build error occurred
21:37:59 Error: > Build failed because of webpack errors
21:37:59 at /vercel/workpath0/node_modules/next/dist/build/index.js:15:918
21:37:59 at async /vercel/workpath0/node_modules/next/dist/build/tracer.js:3:470
21:37:59 error Command failed with exit code 1.
21:37:59 info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
21:37:59 Error: Command "yarn run build" exited with 1
21:38:04 Done with "package.json"
【问题讨论】:
-
/styles/variables/Colors文件是否存在?也许尝试在文件名中完全不使用大写?
标签: javascript reactjs sass next.js vercel