NPM exit code 1



I am trying to add testing for an ionic 2 project.

I haven’t written tests just yet, but when building ionic 2 applications. The framework makes use of a slow compiler (Angular AoT compiler , NGC)

Running the build command before every commit is painful, because I have to wait around 60 seconds for every build.

I added the build command to the test section of my circle.yml which looks like this.

machine: node: version: 4.1.0 general: branches: only: - ionic2.0 dependencies: pre: - npm install -g npm@3.7.0 - npm install -g ionic - npm install -g cordova - npm install test: pre: - ionic build

Everything seems to go fine, the commands are executed properly but there is one issue. Once the test starts & is exited with an exit status of 1 (Build fails), the test section passes as if there weren’t any errors and it thinks my test exited with an exit status of 0.

Excuse the verbose log, but if you scroll down you will see an exit code of 1

NPM log
ionic build

Running 'build:before' npm script before build

> DiGidot-Application@ build /home/ubuntu/digidot-c4-app-fork
> ionic-app-scripts build

[10:46:33]  ionic-app-scripts 0.0.30
[10:46:33]  build prod started ...
[10:46:33]  clean started ...
[10:46:33]  clean finished in 1 ms
[10:46:33]  copy started ...
[10:46:33]  ngc started ...
[10:46:33]  lint started ...
[10:46:33]  copy finished in 202 ms
[10:46:35]  lint finished in 2.16 s
[10:47:05]  ngc: Error: Error at /home/ubuntu/digidot-c4-app-fork/.tmp/pages/triggers/analog/analog.ts:17:32: Cannot find module '../components/input-action-Speed'.
Error at /home/ubuntu/digidot-c4-app-fork/.tmp/pages/triggers/dmx/dmx.ts:16:34: Cannot find module '../components/input-action-Speed'.
Error at /home/ubuntu/digidot-c4-app-fork/.tmp/pages/triggers/power-up/power-up.ts:13:34: Cannot find module '../components/input-action-Speed'.
Error at /home/ubuntu/digidot-c4-app-fork/.tmp/pages/triggers/switch/switch.ts:16:34: Cannot find module '../components/input-action-Speed'.
Error at /home/ubuntu/digidot-c4-app-fork/.tmp/pages/triggers/time/time.ts:19:34: Cannot find module '../components/input-action-Speed'.
    at check (/home/ubuntu/digidot-c4-app-fork/node_modules/@angular/tsc-wrapped/src/tsc.js:31:15)
    at Tsc.typeCheck (/home/ubuntu/digidot-c4-app-fork/node_modules/@angular/tsc-wrapped/src/tsc.js:86:9)
    at /home/ubuntu/digidot-c4-app-fork/node_modules/@angular/tsc-wrapped/src/main.js:33:23
    at process._tickCallback (node.js:356:9)
    at Function.Module.runMain (module.js:477:11)
    at startup (node.js:117:18)
    at node.js:951:3

[10:47:05]  ngc: Compilation failed

[10:47:05]  ngc failed:  NGC encountered an error
[10:47:05]  Error: NGC encountered an error
    at ChildProcess.<anonymous> (/home/ubuntu/digidot-c4-app-fork/node_modules/@ionic/app-scripts/dist/ngc.js:62:24)
    at emitTwo (events.js:87:13)
    at ChildProcess.emit (events.js:172:7)
    at maybeClose (internal/child_process.js:817:16)
    at Process.ChildProcess._handle.onexit (internal/child_process.js:211:5)
Error running ionic app script "build": Error: NGC encountered an error

npm ERR! Linux 3.13.0-91-generic
npm ERR! argv "/opt/circleci/nodejs/v4.1.0/bin/node" "/opt/circleci/nodejs/v4.1.0/bin/npm" "run" "build" "--color"
npm ERR! node v4.1.0
npm ERR! npm  v3.7.0
npm ERR! DiGidot-Application@ build: `ionic-app-scripts build`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the DiGidot-Application@ build script 'ionic-app-scripts build'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the DiGidot-Application package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     ionic-app-scripts build
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs DiGidot-Application
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls DiGidot-Application
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /home/ubuntu/digidot-c4-app-fork/npm-debug.log
Caught exception:

Mind letting us know?

Yet circle CI says the test exited with an error code of 0

I found documentation for a similar problem for RSpec & ruby here

Any idea how I would fix this problem?


If you look at the error message it states that its not able to find the module input-action-speed. If looks like you are only pointing to the folder and not the actual component,


the problem that build is succeeded

  1. I’ve tried
    - set -eo pipefail && npm run lint
  1. and tried luck with npm run lint || exit 1 # Manually Failing a Deployment

  2. and process.exit(1); since my codebase in js

  3. and moved script to dependencies: post as proposed here Fail fast: stop running tests on first failure

  4. and finally wrote a script as described here Build not failing even test exit with code 1

    - |
      set -e
      npm run lint
      if [ "$exitcode" != "0" ]; then exit 1; fi

in spec - - you can find an info about exit codes:

Failing commands (those with a non-zero exit code) will cause the whole build to fail, and you’ll receive a notification

but it’s not like it was described, unfortunately I cannot provide a link to a build as the project is private only an screenshot:

as you can see a lint task returns exit 1 but build doesn’t fail. from another side I’ve tried return exit code 1 directly, and finally it works:

but not in script :angry: wtf

…it drives me nuts