簡體   English   中英

Nextjs:現在運行時拋出錯誤

[英]Nextjs: Throwing an Error when running NOW

將我的應用程序部署到 Now 時,我遇到了這個錯誤。

Automatically optimizing pages...
> Build error occurred
/zeit/5215fad2/node_modules/rc-slider/assets/index.css:1
.rc-slider {
^
SyntaxError: Unexpected token '.'
    at Module._compile (internal/modules/cjs/loader.js:895:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
    at Function.Module._load (internal/modules/cjs/loader.js:727:14)
    at Module.require (internal/modules/cjs/loader.js:852:19)
    at require (internal/modules/cjs/helpers.js:74:18)
    at Object.<anonymous> (/zeit/5215fad2/node_modules/react-jinke-music-player/lib/index.js:72:1)
    at Module._compile (internal/modules/cjs/loader.js:959:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:995:10)
    at Module.load (internal/modules/cjs/loader.js:815:32)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! next-starter-tailwind@1.0.5 build: `next build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the next-starter-tailwind@1.0.5 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!     /zeit/.npm/_logs/2020-01-23T03_03_41_667Z-debug.log
Error: Exited with 1
    at ChildProcess.child.on (/zeit/93391daef1d6236b/.build-utils/.builder/node_modules/@now/next/dist/index.js:47107:24)
    at emitTwo (events.js:126:13)
    at ChildProcess.emit (events.js:214:7)
    at maybeClose (internal/child_process.js:925:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:209:5)
worker exited with code 20 and signal null
done

我在運行“ npm run build ”時遇到了這個問題,但是在使用這個插件( next-transpile-modules )后,它在生產中工作。 但是,當我部署到 Now 時,它拋出了上面的錯誤。 如何解決? 謝謝 !

const withTM = require('next-transpile-modules');

module.exports = withCss(withTM({
  transpileModules: ['rc-slider', 'rc-switch'],
   ...

將您的導入語句更改為

const withTM = require('next-transpile-modules')(['rc-slider','rc-switch'])

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM