Iview-admin: 项目下载下来安装后报错

Created on 4 Jun 2018  ·  4Comments  ·  Source: iview/iview-admin

项目下载下来安装后报错
qq 20180604152524

Most helpful comment

webpack.dev.config.js 和 webpack.prod.config.js 中都有这个问题,需要把

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

修改为

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

All 4 comments

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

buf这个变量有问题,这里不能是string,你试下:const buf = new Buffer('export default "development";');

node.js 10.1.0貌似更改了文件读写的api,有人提了PR但是好像没合并。
image

其实node.js 10的官方文档是不建议new Buffer()这样用的,用Buffer.from会好点。
image

webpack.dev.config.js 和 webpack.prod.config.js 中都有这个问题,需要把

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

修改为

fs.open('./build/env.js', 'w', function(err, fd) {
    const buf = Buffer.from('export default "production";');
    fs.write(fd, buf, 0, buf.length, 0, function(err, written, buffer) {});
});
Was this page helpful?
0 / 5 - 0 ratings