I have a **Create React App, Single Page Application** application.

When I fire **npm run build** command, I get following error :

```
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! roffice@0.1.0 build: `react-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the roffice@0.1.0 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

```

my **package.json** looks like this:

```
   {
  "name": "roffice",
  "version": "0.1.0",
  "private": true,
  "dependencies": {
    "bootstrap": "^4.3.1",
    "chalk": "^2.4.2",
    "child_process": "^1.0.2",
    "jquery": "^3.4.1",
    "jquery-ui": "^1.12.1",
    "jquery-ui-dist": "^1.12.1",
    "list-react-files": "^0.2.0",
    "react": "^16.8.6",
    "react-bell-icon": "^1.0.0",
    "react-bootstrap": "^1.0.0-beta.9",
    "react-confirm-alert": "^2.4.0",
    "react-custom-scrollbars": "^4.2.1",
    "react-datepicker": "^2.7.0",
    "react-dom": "^16.8.6",
    "react-global-configuration": "^1.3.0",
    "react-idle-timer": "^4.2.5",
    "react-input-calendar": "^0.5.4",
    "react-modal": "^3.8.1",
    "react-popper": "^1.3.3",
    "react-router-dom": "^5.0.0",
    "react-scripts": "^3.0.1",
    "react-spinner-material": "^1.1.1",
    "rxjs": "^6.4.0",
    "rxjs-compat": "^6.4.0",
    "save-file": "^2.3.1",
    "sys": "0.0.1",
    "underscore": "^1.9.1"
  },
  "scripts": {
    "start": "set PORT=3006 && react-scripts start",
    "build": "react-scripts --max_old_space_size=8192 build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },
  "eslintConfig": {
    "extends": "react-app",
    "globals": {
      "window": true,
      "ActiveXObject": true
    }
  },
  "browserslist": [
    ">0.2%",
    "not dead",
    "not ie <= 11",
    "not op_mini all"
  ]
}

```

I have been through similar questions on SO, but they didn't help, so kindly don't mark it as duplicate. 

I am stuck here, any help is appreciated.

EDIT :

complete error logs:

```
0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node', '/usr/local/bin/npm', 'run', 'build' ]
2 info using npm@6.4.1
3 info using node@v10.15.2
4 verbose run-script [ 'prebuild', 'build', 'postbuild' ]
5 info lifecycle roffice@0.1.0~prebuild: roffice@0.1.0
6 info lifecycle roffice@0.1.0~build: roffice@0.1.0
7 verbose lifecycle roffice@0.1.0~build: unsafe-perm in lifecycle true
8 verbose lifecycle roffice@0.1.0~build: PATH: /usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/chandrani.chatterjee/Desktop/New_Roffice/ROffice_React/node_modules/.bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/share/dotnet:~/.dotnet/tools:/Users/chandrani.chatterjee/Library/Android/sdk/platform-tools/:/Users/chandrani.chatterjee/Desktop/sdk/platform-tools/:/Users/chandrani.chatterjee/Library/Android/sdk/platform-tools/:/Users/chandrani.chatterjee/Desktop/sdk/platform-tools/
9 verbose lifecycle roffice@0.1.0~build: CWD: /Users/chandrani.chatterjee/Desktop/New_Roffice/ROffice_React
10 silly lifecycle roffice@0.1.0~build: Args: [ '-c', 'react-scripts build' ]
11 silly lifecycle roffice@0.1.0~build: Returned: code: 1  signal: null
12 info lifecycle roffice@0.1.0~build: Failed to exec build script
13 verbose stack Error: roffice@0.1.0 build: `react-scripts build`
13 verbose stack Exit status 1
13 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:301:16)
13 verbose stack     at EventEmitter.emit (events.js:189:13)
13 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:189:13)
13 verbose stack     at maybeClose (internal/child_process.js:970:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:259:5)
14 verbose pkgid roffice@0.1.0
15 verbose cwd /Users/chandrani.chatterjee/Desktop/New_Roffice/ROffice_React
16 verbose Darwin 17.7.0
17 verbose argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
18 verbose node v10.15.2
19 verbose npm  v6.4.1
20 error code ELIFECYCLE
21 error errno 1
22 error roffice@0.1.0 build: `react-scripts build`
22 error Exit status 1
23 error Failed at the roffice@0.1.0 build script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]

```

EDIT2 : 

After deleting node\_modules and package-lock.json , did npm install -> npm audit fix -> npm run build

got following error:

```
FATAL ERROR: Ineffective mark-compacts near heap limit Allocation failed - JavaScript heap out of memory
 1: 0x10003b1db node::Abort() [/usr/local/bin/node]
 2: 0x10003b3e5 node::OnFatalError(char const*, char const*) [/usr/local/bin/node]
 3: 0x1001a86b5 v8::internal::V8::FatalProcessOutOfMemory(v8::internal::Isolate*, char const*, bool) [/usr/local/bin/node]
 4: 0x100573ad2 v8::internal::Heap::FatalProcessOutOfMemory(char const*) [/usr/local/bin/node]
 5: 0x1005765a5 v8::internal::Heap::CheckIneffectiveMarkCompact(unsigned long, double) [/usr/local/bin/node]
 6: 0x10057244f v8::internal::Heap::PerformGarbageCollection(v8::internal::GarbageCollector, v8::GCCallbackFlags) [/usr/local/bin/node]
 7: 0x100570624 v8::internal::Heap::CollectGarbage(v8::internal::AllocationSpace, v8::internal::GarbageCollectionReason, v8::GCCallbackFlags) [/usr/local/bin/node]
 8: 0x10057cebc v8::internal::Heap::AllocateRawWithLigthRetry(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
 9: 0x10057cf3f v8::internal::Heap::AllocateRawWithRetryOrFail(int, v8::internal::AllocationSpace, v8::internal::AllocationAlignment) [/usr/local/bin/node]
10: 0x10054c884 v8::internal::Factory::NewFillerObject(int, bool, v8::internal::AllocationSpace) [/usr/local/bin/node]
11: 0x1007d4894 v8::internal::Runtime_AllocateInNewSpace(int, v8::internal::Object**, v8::internal::Isolate*) [/usr/local/bin/node]
12: 0x3716a5cdbe3d

```