Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

项目克隆下来后npm install 完成后无法运行 #655

Closed
itxiao6 opened this issue May 19, 2018 · 12 comments
Closed

项目克隆下来后npm install 完成后无法运行 #655

itxiao6 opened this issue May 19, 2018 · 12 comments

Comments

@itxiao6
Copy link

itxiao6 commented May 19, 2018

运行npm run dev
提示

> iview-admin@1.3.1 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! iview-admin@1.3.1 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 iview-admin@1.3.1 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
@MackieLee
Copy link

我也是同样的问题

@nlnjnj
Copy link

nlnjnj commented May 22, 2018

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版本修改为对应的即可。

@MackieLee
Copy link

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

@cuiweiqiang
Copy link

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

@MackieLee
Copy link

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

@SoySauce1024
Copy link

同谢一波, @cuiweiqiang

@noranana
Copy link

确实可以了,感谢@cuiweiqiang

@itxiao6
Copy link
Author

itxiao6 commented May 24, 2018

问题已经解决了是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
});

@DayThink
Copy link

DayThink commented Jun 1, 2018

同谢一波, @cuiweiqiang

@Timedrugs
Copy link

问题确实是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
各位可根据实际修改

@hqzh
Copy link

hqzh commented Nov 9, 2018

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

@itxiao6 itxiao6 closed this as completed Nov 15, 2018
@itxiao6
Copy link
Author

itxiao6 commented Nov 15, 2018

已解决

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

9 participants