vue3+vite build打包内存溢出 Reached heap limit Allocation failed -JavaScript heap out of memory

build打包的时候内存超出限制报错:

FATAL ERROR: Reached heap limit Allocation failed - JavaScript heap out of memory

package.json

"scripts": {

"dev": "vite --host",

"build": "vite build && rm -rf ../lbsmart.public/ecdesigner&&mv ./dist ../lbsmart.public/ecdesigner",

},

解决:

su root

//set NODE_OPTIONS=--max_old_space_size=8096

//export NODE_OPTIONS="–max-old-space-size=8192"

cnpm install -g increase-memory-limit

increase-memory-limit

vue3+vite build打包内存溢出 Reached heap limit Allocation failed -JavaScript heap out of memory_第1张图片

然后还会报错:Error: Cannot find module '../dist/node --max-old-space-size=10240/cli'

从node_modules文件夹中检索 ../dist/node --max-old-space-size=10240/cli'修改为  require('../dist/node/cli')

然后又会报错: Command failed: /Users/ecmaster/node_modules/esbuild/bin/esbuild --service=0.11.3

执行: node ./node_modules/esbuild/install.js

你可能感兴趣的:(javascript,开发语言,ecmascript)