Ionic pro: npm install --quiet --no-optional breaks my build

the build server uses “npm install --quiet --no-optional”

i found out that when i build locally, and do npm install --quiet (without the --no-optional flag) then my build goes well.

however, it seems with the --no-optional flag, something is skipped and later the build breaks,

how can i debug and/or fix this problem? thanks!


here the build error:

$ npm install --quiet --no-optional

> node-sass@4.5.3 install /usr/src/app/node_modules/node-sass
> node scripts/install.js

Downloading binary from https://github.com/sass/node-sass/releases/download/v4.5.3/linux-x64-57_binding.node
Download complete
Binary saved to /usr/src/app/node_modules/node-sass/vendor/linux-x64-57/binding.node
Caching binary to /home/gitlab-runner/.npm/node-sass/4.5.3/linux-x64-57_binding.node

> uglifyjs-webpack-plugin@0.4.6 postinstall /usr/src/app/node_modules/uglifyjs-webpack-plugin
> node lib/post_install.js


> node-sass@4.5.3 postinstall /usr/src/app/node_modules/node-sass
> node scripts/build.js

Binary found at /usr/src/app/node_modules/node-sass/vendor/linux-x64-57/binding.node
Testing binary
Binary is fine
added 552 packages in 23.926s
$ npm install --quiet --no-optional success
$ npm run build
npm info it worked if it ends with ok
npm info using npm@5.3.0
npm info using node@v8.2.1
npm info lifecycle podmarks@0.0.1~prebuild: podmarks@0.0.1
npm info lifecycle podmarks@0.0.1~build: podmarks@0.0.1

> podmarks@0.0.1 build /usr/src/app
> ionic-app-scripts build

[14:41:56]  ionic-app-scripts 3.1.6 
[14:41:56]  build dev started ... 
[14:41:56]  clean started ... 
[14:41:56]  clean finished in 1 ms 
[14:41:56]  copy started ... 
[14:41:56]  deeplinks started ... 
[14:41:57]  deeplinks finished in 192 ms 
[14:41:57]  transpile started ... 
[14:42:01]  transpile finished in 4.83 s 
[14:42:01]  preprocess started ... 
[14:42:01]  preprocess finished in 1 ms 
[14:42:01]  webpack started ... 
[14:42:02]  copy finished in 5.27 s 
[14:42:14]  ionic-app-script task: "build" 
[14:42:14]  Error: ./node_modules/sshpk/lib/formats/ssh-private.js Module not found: Error: Can't resolve 'bcrypt-pbkdf' 
            in '/usr/src/app/node_modules/sshpk/lib/formats' resolve 'bcrypt-pbkdf' in 
            '/usr/src/app/node_modules/sshpk/lib/formats' Parsed request is a module using description file: 
            /usr/src/app/node_modules/sshpk/package.json (relative path: ./lib/formats) Field 'browser' doesn't contain 
            a valid alias configuration after using description file: /usr/src/app/node_modules/sshpk/package.json 
            (relative path: ./lib/formats) resolve as module looking for modules in /usr/src/app/node_modules using 
            description file: /usr/src/app/package.json (relative path: ./node_modules) Field 'browser' doesn't contain 
            a valid alias configuration after using description file: /usr/src/app/package.json (relative path: 
            ./node_modules) using description file: /usr/src/app/package.json (relative path: 
            ./node_modules/bcrypt-pbkdf) no extension Field 'browser' doesn't contain a valid alias configuration 
            /usr/src/app/node_modules/bcrypt-pbkdf doesn't exist .ts Field 'browser' doesn't contain a valid alias 
            configuration /usr/src/app/node_modules/bcrypt-pbkdf.ts doesn't exist .js Field 'browser' doesn't contain a 
            valid alias configuration /usr/src/app/node_modules/bcrypt-pbkdf.js doesn't exist .json Field 'browser' 
            doesn't contain a valid alias configuration /usr/src/app/node_modules/bcrypt-pbkdf.json doesn't exist as 
            directory /usr/src/app/node_modules/bcrypt-pbkdf doesn't exist [/usr/src/app/node_modules/bcrypt-pbkdf] 
            [/usr/src/app/node_modules/bcrypt-pbkdf.ts] [/usr/src/app/node_modules/bcrypt-pbkdf.js] 
            [/usr/src/app/node_modules/bcrypt-pbkdf.json] [/usr/src/app/node_modules/bcrypt-pbkdf] @ 
            ./node_modules/sshpk/lib/formats/ssh-private.js 69:12-35 190:12-35 @ ./node_modules/sshpk/lib/key.js @ 
            ./node_modules/sshpk/lib/index.js @ ./node_modules/http-signature/lib/utils.js @ 
            ./node_modules/http-signature/lib/index.js @ ./node_modules/request/request.js @ 
            ./node_modules/request/index.js @ ./src/providers/rss/rss.ts @ ./src/app/app.module.ts @ 
            ./src/app/main.ts,./node_modules/sshpk/lib/dhe.js Module not found: Error: Can't resolve 'ecc-jsbn' in 
            '/usr/src/app/node_modules/sshpk/lib' resolve 'ecc-jsbn' in '/usr/src/app/node_modules/sshpk/lib' Parsed 
            request is a module using description file: /usr/src/app/node_modules/sshpk/package.json (relative path: 
            ./lib) Field 'browser' doesn't contain a valid alias configuration after using description file: 
            /usr/src/app/node_modules/sshpk/package.json (relative path: ./lib) resolve as module looking for modules in 
            /usr/src/app/node_modules using description file: /usr/src/app/package.json (relative path: ./node_modules) 
            Field 'browser' doesn't contain a valid alias configuration after using description file: 
            /usr/src/app/package.json (relative path: ./node_modules) using description file: /usr/src/app/package.json 
            (relative path: ./node_modules/ecc-jsbn) no extension Field 'browser' doesn't contain a valid alias 
            configuration /usr/src/app/node_modules/ecc-jsbn doesn't exist .ts Field 'browser' doesn't contain a valid 
            alias configuration /usr/src/app/node_modules/ecc-jsbn.ts doesn't exist .js Field 'browser' doesn't contain 
            a valid alias configuration /usr/src/app/node_modules/ecc-jsbn.js doesn't exist .json Field 'browser' 
            doesn't contain a valid alias configuration /usr/src/app/node_modules/ecc-jsbn.json doesn't exist as 
            directory /usr/src/app/node_modules/ecc-jsbn doesn't exist [/usr/src/app/node_modules/ecc-jsbn] 
            [/usr/src/app/node_modules/ecc-jsbn.ts] [/usr/src/app/node_modules/ecc-jsbn.js] 
            [/usr/src/app/node_modules/ecc-jsbn.json] [/usr/src/app/node_modules/ecc-jsbn] @ 
            ./node_modules/sshpk/lib/dhe.js 46:11-30 375:10-29 @ ./node_modules/sshpk/lib/private-key.js @ 
            ./node_modules/sshpk/lib/index.js @ ./node_modules/http-signature/lib/utils.js @ 
            ./node_modules/http-signature/lib/index.js @ ./node_modules/request/request.js @ 
            ./node_modules/request/index.js @ ./src/providers/rss/rss.ts @ ./src/app/app.module.ts @ 
            ./src/app/main.ts,./node_modules/sshpk/lib/dhe.js Module not found: Error: Can't resolve 'ecc-jsbn/lib/ec' 
            in '/usr/src/app/node_modules/sshpk/lib' resolve 'ecc-jsbn/lib/ec' in '/usr/src/app/node_modules/sshpk/lib' 
            Parsed request is a module using description file: /usr/src/app/node_modules/sshpk/package.json (relative 
            path: ./lib) Field 'browser' doesn't contain a valid alias configuration after using description file: 
            /usr/src/app/node_modules/sshpk/package.json (relative path: ./lib) resolve as module looking for modules in 
            /usr/src/app/node_modules using description file: /usr/src/app/package.json (relative path: ./node_modules) 
            Field 'browser' doesn't contain a valid alias configuration after using description file: 
            /usr/src/app/package.json (relative path: ./node_modules) using description file: /usr/src/app/package.json 
            (relative path: ./node_modules/ecc-jsbn/lib/ec) no extension Field 'browser' doesn't contain a valid alias 
            configuration /usr/src/app/node_modules/ecc-jsbn/lib/ec doesn't exist .ts Field 'browser' doesn't contain a 
            valid alias configuration /usr/src/app/node_modules/ecc-jsbn/lib/ec.ts doesn't exist .js Field 'browser' 
            doesn't contain a valid alias configuration /usr/src/app/node_modules/ecc-jsbn/lib/ec.js doesn't exist .json 
            Field 'browser' doesn't contain a valid alias configuration /usr/src/app/node_modules/ecc-jsbn/lib/ec.json 
            doesn't exist as directory /usr/src/app/node_modules/ecc-jsbn/lib/ec doesn't exist 
            [/usr/src/app/node_modules/ecc-jsbn/lib/ec] [/usr/src/app/node_modules/ecc-jsbn/lib/ec.ts] 
            [/usr/src/app/node_modules/ecc-jsbn/lib/ec.js] [/usr/src/app/node_modules/ecc-jsbn/lib/ec.json] 
            [/usr/src/app/node_modules/ecc-jsbn/lib/ec] @ ./node_modules/sshpk/lib/dhe.js 48:9-35 377:8-34 @ 
            ./node_modules/sshpk/lib/private-key.js @ ./node_modules/sshpk/lib/index.js @ 
            ./node_modules/http-signature/lib/utils.js @ ./node_modules/http-signature/lib/index.js @ 
            ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./src/providers/rss/rss.ts @ 
            ./src/app/app.module.ts @ ./src/app/main.ts,./node_modules/sshpk/lib/dhe.js Module not found: Error: Can't 
            resolve 'jsbn' in '/usr/src/app/node_modules/sshpk/lib' resolve 'jsbn' in 
            '/usr/src/app/node_modules/sshpk/lib' Parsed request is a module using description file: 
            /usr/src/app/node_modules/sshpk/package.json (relative path: ./lib) Field 'browser' doesn't contain a valid 
            alias configuration after using description file: /usr/src/app/node_modules/sshpk/package.json (relative 
            path: ./lib) resolve as module looking for modules in /usr/src/app/node_modules using description file: 
            /usr/src/app/package.json (relative path: ./node_modules) Field 'browser' doesn't contain a valid alias 
            configuration after using description file: /usr/src/app/package.json (relative path: ./node_modules) using 
            description file: /usr/src/app/package.json (relative path: ./node_modules/jsbn) no extension Field 
            'browser' doesn't contain a valid alias configuration /usr/src/app/node_modules/jsbn doesn't exist .ts Field 
            'browser' doesn't contain a valid alias configuration /usr/src/app/node_modules/jsbn.ts doesn't exist .js 
            Field 'browser' doesn't contain a valid alias configuration /usr/src/app/node_modules/jsbn.js doesn't exist 
            .json Field 'browser' doesn't contain a valid alias configuration /usr/src/app/node_modules/jsbn.json 
            doesn't exist as directory /usr/src/app/node_modules/jsbn doesn't exist [/usr/src/app/node_modules/jsbn] 
            [/usr/src/app/node_modules/jsbn.ts] [/usr/src/app/node_modules/jsbn.js] 
            [/usr/src/app/node_modules/jsbn.json] [/usr/src/app/node_modules/jsbn] @ ./node_modules/sshpk/lib/dhe.js 
            50:11-26 379:10-25 @ ./node_modules/sshpk/lib/private-key.js @ ./node_modules/sshpk/lib/index.js @ 
            ./node_modules/http-signature/lib/utils.js @ ./node_modules/http-signature/lib/index.js @ 
            ./node_modules/request/request.js @ ./node_modules/request/index.js @ ./src/providers/rss/rss.ts @ 
...
...
etc.etc.

ok “fixed” it by simply adding the (not so) optional dependencies to the package.json…

How Because i am also getting same issue on dashboard