厦门微信网站建设,海南注册公司税收优惠政策,营销传播服务,简历模板大学生免费项目过大运行项目内存溢出
报错代码 运行内存溢出 increase-memory-limit ‘“node --max-old-space-size8192”’ 不是内部或外部命令#xff0c;也不是可运行的程序 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of m…项目过大运行项目内存溢出
报错代码 运行内存溢出 increase-memory-limit ‘“node --max-old-space-size8192”’ 不是内部或外部命令也不是可运行的程序 FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory ‘cross-env‘ 不是内部或外部命令也不是可运行的程序 或批处理文件 解决方案
1.第一步安装 使用 increase-memory-limit
npm install --save-dev increase-memory-limit
npm install --save-dev cross-env安装完成插件在package.json scripts中添加下面代码并运行
limit: cross-env LIMIT8192 increase-memory-limit,2.第二步替换 “%_prog%” 如果报错 “不是内部或外部命令” 在根目录下 新建与node-modules同级的文件increase-memory-limit.js把wfpath改成自己的项目地址即可注意有两处地方需要调整
const fs require(fs)
function replaceStr(filePath, sourceRegx, targetSrt) { //文件路径、 需要修改的字符串、修改后的字符串fs.readFile(filePath, (err, data) {if (err) console.log(err)else {let str data.toString();str str.replace(sourceRegx, targetSrt);fs.writeFile(filePath, str, (err) {if (err) console.log(err);})}})
}
var wfPath D:/mgsworker/newTran/node_modules/.bin
fs.readdir(wfPath, (err, files) {if (err) console.log(err);else {if (files.length ! 0) {files.forEach((item) {var wfPath D:/mgsworker/newTran/node_modules/.bin;// 或者var wfPath path.resolve(__dirname, ../node_modules/.bin)if (item.split(.)[1] cmd) {wfPath /${item};replaceStr(wfPath, /%_prog%/, %_prog%)}})}}
})3.第三步运行替换 文件根目录下执行命令node increase-memory-limit.js 执行完可以删除脚本文件
4.第四步正常运行和打包了
补充
当npm install 运行报错的时候 多半是源的问题 因为访问https://registry.npmjs.org这个地址需要翻墙才能访问所以在国内经常会出现连接超时等问题。为了解决这个问题可以将npm的源设置为国内的镜像例如淘宝镜像。
npm config set registry https://registry.npmmirror.com
npm config get registry // 查看设置npm 官方原始镜像网址是https://registry.npmjs.org/ 淘宝最新 NPM 镜像https://registry.npmmirror.com 阿里云 NPM 镜像 https://npm.aliyun.com 腾讯云 NPM 镜像https://mirrors.cloud.tencent.com/npm/ 华为云 NPM 镜像https://mirrors.huaweicloud.com/repository/npm/ 网易 NPM 镜像https://mirrors.163.com/npm/ 中科院大学开源镜像站http://mirrors.ustc.edu.cn/ 清华大学开源镜像站https://mirrors.tuna.tsinghua.edu.cn/