node.js - Nextjs:现在运行时抛出错误
问题描述
将我的应用程序部署到 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'])
推荐阅读
- vue.js - 有没有办法在 nuxt / vue 环境中更漂亮地修复这个错误
- swift - RealityKit 自定义 ARAnchor 未跨设备同步
- javascript - CountUp 函数无法从 0 递增到输入的时间
- node.js - 如何修复 websocket 无效的帧头?
- javascript - 减少多维数组以获得给定数组的sum/avg/min/max
- java - 安全连接 DBNAME.zip 上传到存储库是否安全?
- c# - 时间:2018-01-10 标签:c#nulling a item of generic list (List
) 真的 - sql - 如何从表中选择数据(具有一种十进制类型)并插入另一个表(具有不同的十进制类型)
- python - CV2 相机 - Python
- c - 以下 C 语言语句 -1<<1 的输出是什么?