This error is reported when NPM run build is executed to package Vue project, because the maximum value of node file set is not enough and the file after project packaging is too large.
Solution: install increase memory limit globally
Command line CMD, DOS window running: cnpm install – G increase memory limit,
Enter the project folder and run: increase memory limit
If NPM run build reports an error ‘node — Max old space size = 10240’ after executing increase memory limit after entering the project file, it is neither an internal or external command nor a runnable program ‘
You can create the following JS file contents in the project root directory, execute the file with node, and then run NPM run build to package successfully. This is to replace the public function of the string in the file corresponding to the. Bin file under the node_mosules file.
// Execute this script via node the first time you run the project
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%')
}
})
}
}
})
// Parameters: [file path, string to be modified, modified string] (public function to replace the string in the corresponding file)
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) })
}
})
}
Read More:
- [Solved] Ineffective mark-compacts near heap limit Allocation failed – JavaScript heap out of memory
- [Solved] Vue Project Modify Page Error: CALL_AND_RETRY_LAST Allocation failed – JavaScript heap out of memory
- [Solved] Project Package Error: Javascript heap out of memory
- [Solved] NPM err! Cannot read property ‘parent’ of null npm ERR! A complete log of this run can be found in: npm ERR!
- [Solved] Vue Compile Error: JavaScript heap out of memory
- [Solved] npm Install vuex Error: npm ERR! code ERESOLVE
- [Solved] VUE npm install Error: Module build failed: Error: ENOENT: no such file or directory, scandir
- [Solved] Package Install Error: npm ERR code ERR_SOCKET_TIMEOUT npm ERR
- npm ERR code ELIFECYCLE [How to Solve]
- [Solved] Vue3 npm ERR code ERR_SSL_DECRYPTION_FAILED_OR_BAD_RECORD_MAC
- [Solved] VSCode package Error: Command failed: npm list –production –parseable –depth=99999 –loglevel=error
- [Solved] VUE3 Error: Error: ENOSPC: System limit for number of file watchers reached
- How to Solve NPM installation -g @view/client Error
- [Solved] npm Error: Class extends value undefined is not a constructor or null
- [Solved] Vue create Create Project Error: command failed: npm install –loglevel error
- [Solved] Vue create error: ERROR: command failed: npm install –loglevel error
- npm run dev Error: opensslErrorStack: [ ‘error:03000086:digital envelope routines::initialization error‘ ]
- [Solved] NPM node ERROR in main..js from Terser ChildProcessWorker.initialize Excaption
- NPM publish an angular library Error [How to Solve]
- NPM run dev runs the Vue project and reports an error: Node Sass does not yet support your current environment