将应用程序部署到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'],
...
答案 0 :(得分:-1)
将导入语句更改为
withTM const = require('next-transpile-modules')([['rc-slider','rc-switch'])