2

I created a project using Angular 12 and everything works fine. However, I get an issue when I try to build the project. I get the following error:

ng build
⠋ Generating browser application bundles (phase: setup)...Compiling @angular/core : es2015 as esm2015
Compiling @angular/common : es2015 as esm2015
Compiling @angular/platform-browser : es2015 as esm2015
Compiling @angular/router : es2015 as esm2015
Compiling @angular/platform-browser-dynamic : es2015 as esm2015
⠴ Generating browser application bundles (phase: building)...events.js:377
      throw er; // Unhandled 'error' event
      ^

Error: spawn .../node_modules/esbuild/bin/esbuild EACCES
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:467:16)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
    at runNextTicks (internal/process/task_queues.js:64:3)
    at processImmediate (internal/timers.js:437:9)
Emitted 'error' event on ChildProcess instance at:
    at Process.ChildProcess._handle.onexit (internal/child_process.js:275:12)
    at onErrorNT (internal/child_process.js:467:16)
    [... lines matching original stack trace ...]
    at processImmediate (internal/timers.js:437:9) {
  errno: -13,
  code: 'EACCES',
  syscall: 'spawn .../node_modules/esbuild/bin/esbuild',
  path: '.../node_modules/esbuild/bin/esbuild',
  spawnargs: [ '--service=0.12.24', '--ping' ]
}

My ng version is:

     _                      _                 ____ _     ___
    / \   _ __   __ _ _   _| | __ _ _ __     / ___| |   |_ _|
   / △ \ | '_ \ / _` | | | | |/ _` | '__|   | |   | |    | |
  / ___ \| | | | (_| | |_| | | (_| | |      | |___| |___ | |
 /_/   \_\_| |_|\__, |\__,_|_|\__,_|_|       \____|_____|___|
                |___/
    

Angular CLI: 12.2.5
Node: 14.17.6
Package Manager: npm 6.14.15
OS: linux x64

Angular: 12.2.5
... animations, cli, common, compiler, compiler-cli, core, forms
... platform-browser, platform-browser-dynamic, router

Package                         Version
---------------------------------------------------------
@angular-devkit/architect       0.1202.5
@angular-devkit/build-angular   12.2.5
@angular-devkit/core            12.2.5
@angular-devkit/schematics      12.2.5
@schematics/angular             12.2.5
rxjs                            6.6.7
typescript                      4.3.5

I have removed the node modules like five times and re-did the npm install even with sudo but I still get the same exact issue.

Richard Matovu
  • 501
  • 4
  • 15
  • You should not install your modules with root. try reinstall it with a normal user and add unsafe-perm flag `npm i --unsafe-perm=true` – tbarbot Sep 15 '21 at 07:21
  • I think you are trying to build the project in your c drive and might be c drive doesn't allow to write file itself. I believe you are admin user. If not then try to build the project in your username. Here is issue that might help you [https://github.com/evanw/esbuild/issues/369] – Sanoj_V Sep 15 '21 at 07:27
  • I am using Linux not windows. In addition, that issue is for npm install. My npm install is okay. The issue is on ng build. – Richard Matovu Sep 15 '21 at 07:42

1 Answers1

1

Try to run below command first:

node ./node_modules/esbuild/install.js

and then ng build

Suneet Bansal
  • 2,664
  • 1
  • 14
  • 18
  • When I run that i get: The version of the downloaded binary is incorrect: spawnSync .../node_modules/esbuild/bin/esbuild__ EACCES Install unsuccessful – Richard Matovu Sep 15 '21 at 12:53