首页 > 解决方案 > webpack next.js TypeError:“原始”参数必须是函数类型

问题描述

运行npm run dev的时候报错:如果有懂的请教教我

// 错误内容

TypeError:“原始”参数必须是函数类型

./node_modules/node-libs-browser/node_modules/util/util.js:602 599 | 600 | export.promisify = function promisify(original) { 601 | if (typeof original !== 'function')

602 | throw new TypeError('“原始”参数必须是函数类型'); 603 | 604 | if (kCustomPromisifiedSymbol && original[kCustomPromisifiedSymbol]) { 605 | var fn = original[kCustomPromisifiedSymbol];

// next.config.js
const withSass = require('@zeit/next-sass');
module.exports = withSass({
  /* config options here */
});

module.exports = {
  webpack: config => {
   config.node = {
     fs: 'empty',
     child_process: 'empty',
     net: 'empty',
     dns: 'empty',
     tls: 'empty',
   };
   return config;
  },
};


// packege.json

    > "dependencies": {
    >     "@types/react-intl": "^3.0.0",
    >     "@types/react-lottie": "^1.2.3",
    >     "@zeit/next-sass": "^1.0.1",
    >     "child_process": "^1.0.2",
    >     "googleapis": "^49.0.0",
    >     "isomorphic-unfetch": "^3.0.0",
    >     "next": "^9.2.1",
    >     "node-sass": "^4.13.1",
    >     "react": "^16.12.0",
    >     "react-dom": "^16.12.0",
    >     "react-intl": "^3.12.0",
    >     "react-lottie": "^1.2.3"   },   "devDependencies": {
    >     "@types/node": "^13.7.0",
    >     "@types/react": "^16.9.19",
    >     "typescript": "^3.7.5"   }

标签: webpacknext.jswebpack-dev-server

解决方案


推荐阅读