Jireh程序猿的那些事 Jireh程序猿的那些事

记录分享生活、程序、信息的精彩人生

目录
node --max-old-space-size=10240 不是内部或外部命令,也不是可运行的程序
/  

node --max-old-space-size=10240 不是内部或外部命令,也不是可运行的程序

解决

'"node --max-old-space-size=10240"' 不是内部或外部命令,也不是可运行的程序错误

在项目根目录下创建一个空的js文件

// 第一次运行项目时通过node执行此脚本
const fs = require('fs')
const path = require('path')
const wfPath =  path.resolve(__dirname, './node_modules/.bin')

fs.readdir(wfPath, (err, files)=>{
   if (err) {
    console.log(err);
   } else {
      if(files.length != 0 ) {
        files.forEach((item)=>{
           if(item.split('.')[1] === 'cmd') {
              replaceStr(`${wfPath}/${item}`, /"%_prog%"/, '%_prog%')
           }
        })
     }
   }
 })

// 参数:[文件路径、 需要修改的字符串、修改后的字符串] (替换对应文件内字符串的公共函数)
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)=> { console.log(err) })
     }
  })
}

然后通过node执行此脚本即可


如果觉得这篇文章不错的话,请我喝一杯 咖啡☕吧
标题:node --max-old-space-size=10240 不是内部或外部命令,也不是可运行的程序
作者:Jireh
地址:https://jireh.xyz/articles/2021/09/01/1630486876748.html
本作品由 Jireh 采用 署名 – 非商业性使用 – 禁止演绎 4.0 国际许可协议进行许可,转载请注明出处。