Tag Archives: iview npm run dev

[Solved] IView NPM run dev run error: TypeError [ERR_INVALID_CALLBACK]: Callback must be a function

 1 > [email protected] dev D:\Download\iview-project-3.0
 2 > webpack-dev-server --content-base ./ --open --inline --hot --compress --history-api-fallback --config webpack.dev.config.js
 3 
 4 fs.js:128
 5   throw new ERR_INVALID_CALLBACK();
 6   ^
 7 
 8 TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
 9     at maybeCallback (fs.js:128:9)
10     at Object.write (fs.js:540:14)
11     at D:\Download\iview-project-3.0\webpack.dev.config.js:10:8
12     at FSReqWrap.args [as oncomplete] (fs.js:140:20)
13 npm ERR! code ELIFECYCLE
14 npm ERR! errno 1
15 npm ERR! [email protected] dev: `webpack-dev-server --content-base ./ --open --inline --hot --compress --history-api-fallback --config webpack.dev.config.js`
16 npm ERR! Exit status 1
17 npm ERR!
18 npm ERR! Failed at the [email protected] dev script.
19 npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
20 
21 npm ERR! A complete log of this run can be found in:
22 npm ERR!     C:\Users\Administrator\AppData\Roaming\npm-cache\_logs\2019-08-17T02_20_31_857Z-debug.log

After downloading the official engineering documents   After iView Projcet, run NPM run Dev and an error will be reported, as shown above

A solution was found later:

In the webpack. * config file, modify it to the corresponding node according to your current node version

1 fs.open(‘./build/env.js‘, ‘w‘, function(err, fd) {
2     const buf = ‘export default "development";‘;
3     // node version problem
4     // fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {}); // node --version > v10.1.0
5     fs.write(fd, buf, function(err, written, buffer) {}); // node --version < v10.1.0
6 });