Iview-admin: 项目克隆下来后npm install 完成后无法运行

Created on 19 May 2018  ·  12Comments  ·  Source: iview/iview-admin

运行npm run dev
提示

> [email protected] dev /Users/itxiao6/Desktop/iview-admin
> webpack-dev-server --content-base ./ --open --inline --hot --compress --config build/webpack.dev.config.js

Happy[happybabel]: Version: 4.0.1. Threads: 8 (shared pool)
fs.js:140
  throw new ERR_INVALID_CALLBACK();
  ^

TypeError [ERR_INVALID_CALLBACK]: Callback must be a function
    at maybeCallback (fs.js:140:9)
    at Object.fs.write (fs.js:656:14)
    at /Users/itxiao6/Desktop/iview-admin/build/webpack.dev.config.js:12:8
    at FSReqWrap.oncomplete (fs.js:152:20)
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! [email protected] dev: `webpack-dev-server --content-base ./ --open --inline --hot --compress --config build/webpack.dev.config.js`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] dev 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!     /Users/itxiao6/.npm/_logs/2018-05-19T06_30_59_396Z-debug.log

Most helpful comment

我发 pr 了,作者还没合,不过你可以参照着改下试试。

All 12 comments

我也是同样的问题

webpack.*.config

fs.open('./build/env.js', 'w', function(err, fd) {
    const buf = 'export default "development";';
    fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {});
});

这个fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {});根据你当前的node版本修改为对应的即可。

和这个没关系,我的nodejs是10.1.0版本,文件中的写法和官方文档中是一样的。楼上的,你试过用你说的这个方法解决了么?

我发 pr 了,作者还没合,不过你可以参照着改下试试。

谢谢楼上前辈,给了正解。

同谢一波, @cuiweiqiang

确实可以了,感谢@cuiweiqiang

问题已经解决了是node 的版本问题
文件:build/webpack.base.dev.cinfig.js
位置:大概在第10行

fs.open('./build/env.js', 'w', function(err, fd) {
    const buf = 'export default "development";';
    // node 版本问题
    // fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {}); // node --version > v10.1.0
    fs.write(fd, buf, function(err, written, buffer) {}); // node --version < v10.1.0
});

同谢一波, @cuiweiqiang

问题确实是node版本的原因,

问题已经解决了是node 的版本问题
文件:build/webpack.base.dev.cinfig.js
位置:大概在第10行

fs.open('./build/env.js', 'w', function(err, fd) {
    const buf = 'export default "development";';
    // node 版本问题
    // fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {}); // node --version > v10.1.0
    fs.write(fd, buf, function(err, written, buffer) {}); // node --version < v10.1.0
});

确实是node版本问题 但是我修改的却和版主相反
我的修改如下:
// fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {}); // node --version < v10.1.0
fs.write(fd, buf, function(err, written, buffer) {}); // node --version > v10.1.0
各位可根据实际修改

各个项目node版本不一致建议下载一个node切换器nvm ,这样不用考虑会破坏脚手架,而且切换也柔顺丝滑

已解决

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zhangwei900808 picture zhangwei900808  ·  5Comments

codeItachi picture codeItachi  ·  5Comments

sharpfeel picture sharpfeel  ·  5Comments

ptlinyi picture ptlinyi  ·  4Comments

tinnkm picture tinnkm  ·  4Comments