由于 webpack 错误,部署 next.js 应用程序构建失败时出错

时间:2021-05-14 21:46:59

标签: node.js heroku webpack next.js

我正在尝试部署我的应用程序,后端上传得很好,但现在我在尝试上传 Next.js 中制作的前端时遇到了很多问题

-----> Building on the Heroku-20 stack
-----> Determining which buildpack to use for this app
-----> Node.js app detected
       
-----> Creating runtime environment
       
       NPM_CONFIG_LOGLEVEL=error
       NODE_VERBOSE=false
       NODE_ENV=production
       NODE_MODULES_CACHE=true
       
-----> Installing binaries
       engines.node (package.json):  unspecified
       engines.npm (package.json):   unspecified (use default)
       
       Resolving node version 14.x...
       Downloading and installing node 14.17.0...
       Using default npm version: 6.14.13
       
-----> Installing dependencies
       Installing node modules
       
       > fsevents@1.2.13 install /tmp/build_7edc0468/node_modules/webpack-dev-server/node_modules/fsevents
       > node install.js
       
       
       Skipping 'fsevents' build as platform linux is not supported
       added 851 packages in 13.302s
       
-----> Build
       Running build
       
       > client@1.0.0 build /tmp/build_7edc0468
       > next build
       
       info  - Using webpack 5. Reason: no next.config.js https://nextjs.org/docs/messages/webpack5
       warn  - No build cache found. Please configure build caching for faster rebuilds. Read more:
 https://nextjs.org/docs/messages/no-cache
       info  - Checking validity of types...
       Attention: Next.js now collects completely anonymous telemetry regarding usage.
       This information is used to shape Next.js' roadmap and prioritize features.
       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:
       https://nextjs.org/telemetry
       
       info  - Creating an optimized production build... (node:890) [DEP_WEBPACK_MODULE_ISSUER] DeprecationWarning: Module.issuer: Use new
 ModuleGraph API (Use `node --trace-deprecation ...` to show where the
 warning was created) Failed to compile. ./static/css/styles.css CSS
 cannot be imported within pages/_document.js. Please move global
 styles to pages/_app.js. Location: pages/_document.js
> Build error occurred Error: > Build failed because of webpack errors
    at /tmp/build_7edc0468/node_modules/next/dist/build/index.js:17:924
    at async Span.traceAsyncFn (/tmp/build_7edc0468/node_modules/next/dist/telemetry/trace/trace.js:6:584)
 npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! client@1.0.0 build:
 `next build` npm ERR! Exit status 1 npm ERR!  npm ERR! Failed at the
 client@1.0.0 build script. npm ERR! This is probably not a problem
 with npm. There is likely additional logging output above. npm ERR! A
 complete log of this run can be found in: npm ERR!    
 /tmp/npmcache.mFr6S/_logs/2021-05-14T21_21_50_520Z-debug.log
-----> Build failed
       
       We're sorry this build is failing! You can troubleshoot common issues here:
       https://devcenter.heroku.com/articles/troubleshooting-node-deploys
       
       Some possible problems:
       
       - Node version not specified in package.json
         https://devcenter.heroku.com/articles/nodejs-support#specifying-a-node-js-version
       
       Love,
       Heroku
         !     Push rejected, failed to compile Node.js app.  !     Push failed

0 个答案:

没有答案