Ionic Pro build fails remote, a local build --prod works fine

I have this strange error when trying to git push my latest version to ionic pro platform.
In this log you see the ionic build --prod fails but on my local machine this is just building well !

The error says "Cannot find module ‘./_rules’ which is something I never heared of before.
Googling for it didn’t take me any further…

Any ideas please ?

npm install succeeded
remote: Detected local install of ionic cli…
remote: Running: ionic build --prod
remote: [ANNOUNCE] Hi! Welcome to CLI 3.9.
remote:
remote: We decided to merge core plugins back into the main ionic CLI package. The @ionic/cli-plugin-ionic-angular, @ionic/cli-plugin-ionic1, @ionic/cli-plugin-cordova, and @ionic/cli-plugin-gulp plugins have all been deprecated and won’t be loaded by the CLI anymore. We listened to devs and determined they added unnecessary complexity. You can uninstall them from your project(s).
remote:
remote: No functionality was removed and all commands will continue working normally. You may wish to review the CHANGELOG: https://github.com/ionic-team/ionic-cli/blob/master/CHANGELOG.md#changelog
remote:
remote: Thanks,
remote: The Ionic Team
remote:
remote:
remote: Error: Cannot find module ‘./_rules’
remote: ionic build failed…falling back to npm run build
remote: Running: npm run build
remote: npm info it worked if it ends with ok
remote: npm info using npm@5.3.0
remote: npm info using node@v8.2.1
remote: npm info lifecycle prono@0.0.1~prebuild: prono@0.0.1
remote: npm info lifecycle prono@0.0.1~build: prono@0.0.1
remote:
remote: > prono@0.0.1 build /usr/src/app
remote: > ionic-app-scripts build
remote:
remote: module.js:487
remote: throw err;
remote: ^
remote:
remote: Error: Cannot find module ‘./_rules’
remote: at Function.Module._resolveFilename (module.js:485:15)
remote: at Function.Module._load (module.js:437:25)
remote: at Module.require (module.js:513:17)
remote: at require (internal/module.js:11:18)
remote: at Object. (/usr/src/app/node_modules/ajv/lib/compile/rules.js:3:19)
remote: at Module._compile (module.js:569:30)
remote: at Object.Module._extensions…js (module.js:580:10)
remote: at Module.load (module.js:503:32)
remote: at tryModuleLoad (module.js:466:12)
remote: at Function.Module._load (module.js:458:3)
remote: npm info lifecycle prono@0.0.1~build: Failed to exec build script
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! prono@0.0.1 build: ionic-app-scripts build
remote: npm ERR! Exit status 1
remote: npm ERR!
remote: npm ERR! Failed at the prono@0.0.1 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote:
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR! /home/gitlab-runner/.npm/_logs/2017-08-26T15_39_42_199Z-debug.log
remote: npm run build failed

What is your local ionic info output?

cli packages: (/Users/robrechtvanmelckebeke/git/prono/node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 6.5.0 

local packages:

@ionic/app-scripts : 2.1.3
Cordova Platforms  : android 6.1.2 ios 4.3.1
Ionic Framework    : ionic-angular 3.5.0

System:

ios-deploy : 1.9.1 
ios-sim    : 5.0.13 
Node       : v7.5.0
npm        : 4.1.2 
OS         : macOS Sierra
Xcode      : Xcode 8.3.3 Build version 8E3004b

If there is no specific reason to keep these old versions, update to the most current ones.

Also:

(from the first output you posted) Take care of this.

Please take a look at included log file.
I first updated cordova CLI + platforms, they have higher version numbers now according to ionic
Then I uninstalled the cli-plugin with “npm uninstall @ionic/…”

Running the build --prod still works fine, the remote build still fails…

Thanks

> MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ ionic info

cli packages: (/Users/robrechtvanmelckebeke/git/prono/node_modules)

    @ionic/cli-utils  : 1.9.2
    ionic (Ionic CLI) : 3.9.2

global packages:

    Cordova CLI : 7.0.1 

local packages:

    @ionic/app-scripts : 2.1.3
    Cordova Platforms  : android 6.2.3 ios 4.4.0
    Ionic Framework    : ionic-angular 3.5.0

System:

    ios-deploy : 1.9.1 
    ios-sim    : 5.0.13 
    Node       : v7.5.0
    npm        : 4.1.2 
    OS         : macOS Sierra
    Xcode      : Xcode 8.3.3 Build version 8E3004b
MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ git push ionic master
Enter passphrase for key '/Users/robrechtvanmelckebeke/.ssh/ionic/456615_rsa': 
Counting objects: 280, done.
Delta compression using up to 8 threads.
Compressing objects: 100% (267/267), done.
Writing objects: 100% (280/280), 116.54 KiB | 0 bytes/s, done.
Total 280 (delta 182), reused 0 (delta 0)
remote: Creating build for master branch from e5bf7d5 (Updated ios and android platforms).
remote: New commit or branch detected triggering new build...
remote: Running with gitlab-ci-multi-runner 9.1.0 (0118d89)
remote:   on IonicJS Snapshot Runner (6c67ff43)
remote: Using Shell executor...
remote: Running on ip-172-31-11-42...
remote: Cloning repository...
remote: Cloning into '/home/gitlab-runner/builds/6c67ff43/0/project-1'...
remote: 
remote: Checking out e5bf7d51 as master...
remote: Skipping Git submodules setup
remote: $ fetch-updates
remote: 
remote: Checking for build process updates...
remote: $ build-app
remote: Fetching build dependencies...
remote: 
remote: Running: npm install
remote: 
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: buffer-shims@1.0.0 (node_modules/fsevents/node_modules/buffer-shims):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/buffer-shims' -> '/usr/src/app/node_modules/fsevents/node_modules/.buffer-shims.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: concat-map@0.0.1 (node_modules/fsevents/node_modules/concat-map):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/concat-map' -> '/usr/src/app/node_modules/fsevents/node_modules/.concat-map.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: extsprintf@1.0.2 (node_modules/fsevents/node_modules/extsprintf):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/extsprintf' -> '/usr/src/app/node_modules/fsevents/node_modules/.extsprintf.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: jodid25519@1.0.2 (node_modules/fsevents/node_modules/jodid25519):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/jodid25519' -> '/usr/src/app/node_modules/fsevents/node_modules/.jodid25519.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: json-schema@0.2.3 (node_modules/fsevents/node_modules/json-schema):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/json-schema' -> '/usr/src/app/node_modules/fsevents/node_modules/.json-schema.DELETE
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ms@2.0.0 (node_modules/fsevents/node_modules/ms):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/ms' -> '/usr/src/app/node_modules/fsevents/node_modules/.ms.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: node-pre-gyp@0.6.36 (node_modules/fsevents/node_modules/node-pre-gyp):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/node-pre-gyp' -> '/usr/src/app/node_modules/fsevents/node_modules/.node-pre-gyp.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: qs@6.4.0 (node_modules/fsevents/node_modules/qs):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/qs' -> '/usr/src/app/node_modules/fsevents/node_modules/.qs.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: verror@1.3.6 (node_modules/fsevents/node_modules/verror):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/verror' -> '/usr/src/app/node_modules/fsevents/node_modules/.verror.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: deep-extend@0.4.2 (node_modules/fsevents/node_modules/deep-extend):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/deep-extend' -> '/usr/src/app/node_modules/fsevents/node_modules/.deep-extend.DELETE
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fstream-ignore@1.0.5 (node_modules/fsevents/node_modules/fstream-ignore):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/fstream-ignore' -> '/usr/src/app/node_modules/fsevents/node_modules/.fstream-ignore.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: ini@1.3.4 (node_modules/fsevents/node_modules/ini):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/ini' -> '/usr/src/app/node_modules/fsevents/node_modules/.ini.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: rc@1.2.1 (node_modules/fsevents/node_modules/rc):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/rc' -> '/usr/src/app/node_modules/fsevents/node_modules/.rc.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: minimist@1.2.0 (node_modules/fsevents/node_modules/rc/node_modules/minimist):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/rc/node_modules/minimist' -> '/usr/src/app/node_modules/fsevents/node_modules/rc/node_modules/.minimist.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: strip-json-comments@2.0.1 (node_modules/fsevents/node_modules/strip-json-comments):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/strip-json-comments' -> '/usr/src/app/node_modules/fsevents/node_modules/.strip-json-comments.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: tar-pack@3.4.0 (node_modules/fsevents/node_modules/tar-pack):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/tar-pack' -> '/usr/src/app/node_modules/fsevents/node_modules/.tar-pack.DELETE'
remote: npm WARN optional SKIPPING OPTIONAL DEPENDENCY: uid-number@0.0.6 (node_modules/fsevents/node_modules/uid-number):
remote: npm WARN enoent SKIPPING OPTIONAL DEPENDENCY: ENOENT: no such file or directory, rename '/usr/src/app/node_modules/fsevents/node_modules/uid-number' -> '/usr/src/app/node_modules/fsevents/node_modules/.uid-number.DELETE'
remote: 
remote: added 131 packages, removed 128 packages and updated 121 packages in 16.263s
remote: npm install succeeded
remote: Detected local install of ionic cli...
remote: Running: ionic build --prod
remote: [ANNOUNCE] Hi! Welcome to CLI 3.9.
remote: 
remote:            We decided to merge core plugins back into the main ionic CLI package. The @ionic/cli-plugin-ionic-angular, @ionic/cli-plugin-ionic1, @ionic/cli-plugin-cordova, and @ionic/cli-plugin-gulp plugins have all been deprecated and won't be loaded by the CLI anymore. We listened to devs and determined they added unnecessary complexity. You can uninstall them from your project(s).
remote:            
remote:            No functionality was removed and all commands will continue working normally. You may wish to review the CHANGELOG: https://github.com/ionic-team/ionic-cli/blob/master/CHANGELOG.md#changelog
remote:            
remote:            Thanks,
remote:            The Ionic Team
remote:            
remote:            
remote: Error: Cannot find module './_rules'
remote: ionic build failed...falling back to npm run build
remote: Running: npm run build
remote: npm info it worked if it ends with ok
remote: npm info using npm@5.3.0
remote: npm info using node@v8.2.1
remote: npm info lifecycle prono@0.0.1~prebuild: prono@0.0.1
remote: npm info lifecycle prono@0.0.1~build: prono@0.0.1
remote: 
remote: > prono@0.0.1 build /usr/src/app
remote: > ionic-app-scripts build
remote: 
remote: module.js:487
remote:     throw err;
remote:     ^
remote: 
remote: Error: Cannot find module './_rules'
remote:     at Function.Module._resolveFilename (module.js:485:15)
remote:     at Function.Module._load (module.js:437:25)
remote:     at Module.require (module.js:513:17)
remote:     at require (internal/module.js:11:18)
remote:     at Object.<anonymous> (/usr/src/app/node_modules/ajv/lib/compile/rules.js:3:19)
remote:     at Module._compile (module.js:569:30)
remote:     at Object.Module._extensions..js (module.js:580:10)
remote:     at Module.load (module.js:503:32)
remote:     at tryModuleLoad (module.js:466:12)
remote:     at Function.Module._load (module.js:458:3)
remote: npm info lifecycle prono@0.0.1~build: Failed to exec build script
remote: npm ERR! code ELIFECYCLE
remote: npm ERR! errno 1
remote: npm ERR! prono@0.0.1 build: `ionic-app-scripts build`
remote: npm ERR! Exit status 1
remote: npm ERR! 
remote: npm ERR! Failed at the prono@0.0.1 build script.
remote: npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
remote: 
remote: npm ERR! A complete log of this run can be found in:
remote: npm ERR!     /home/gitlab-runner/.npm/_logs/2017-08-28T12_04_39_553Z-debug.log
remote: npm run build failed
remote: Make sure your project has an ionic.config.json or a build script in the package.json
remote: Running after script...
remote: $ clean-up
remote: Cleaning up files...
remote: Successful clean up
remote: ERROR: Job failed: exit status 1
remote: 
To git.ionicjs.com:robrechtvm/prono.git
   f56795bf..e5bf7d51  master -> master
MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ npm uninstall @ionic/cli-plugin-ionic-angular @ionic/cli-plugin-cordova
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ npm uninstall @ionic/cli-plugin-ionic1
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ npm uninstall @ionic/cli-plugin-cordova
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ npm uninstall @ionic/cli-plugin-gulp
npm WARN ajv-keywords@2.1.0 requires a peer of ajv@>=5.0.0 but none was installed.
MacBook-Pro-van-Robrecht:prono robrechtvanmelckebeke$ ionic build --prod
[INFO] Running app-scripts build: --prod
       
[14:10:50]  build prod started ... 
[14:10:50]  clean started ... 
[14:10:50]  clean finished in 3 ms 
[14:10:50]  copy started ... 
[14:10:50]  ngc started ... 
[14:10:57]  ngc finished in 7.50 s 
[14:10:57]  preprocess started ... 
[14:10:57]  deeplinks started ... 
[14:10:58]  deeplinks finished in 357 ms 
[14:10:58]  optimization started ... 
[14:10:58]  copy finished in 8.31 s 
[14:11:09]  optimization finished in 11.55 s 
[14:11:09]  preprocess finished in 11.91 s 
[14:11:09]  webpack started ... 
[14:11:27]  webpack finished in 17.47 s 
[14:11:27]  sass started ... 
[14:11:27]  uglifyjs started ... 
[14:11:28]  sass finished in 976 ms 
[14:11:28]  cleancss started ... 
[14:11:29]  cleancss finished in 1.23 s 
[14:11:59]  uglifyjs finished in 32.57 s 
[14:11:59]  postprocess started ... 
[14:12:00]  postprocess finished in 676 ms 
[14:12:00]  lint started ... 
[14:12:00]  build prod finished in 70.18 s 
> ionic cordova prepare
> cordova prepare
⠋ Running command [14:12:07]  lint finished in 6.66 s 
✔ Running command - done!

Sorry, no idea. You will probably have to contact support: http://ionicframework.com/support#support

I am having the exact same problem, did you solve it?

(You should also contact support, but also post your ionic info and complete command output - even if it looks quite similar)

@Sujan12 @racafe
I did contact support but they told me this kind of support is not available in the Kickstarter plan.
So issue is still not solved

Ionic Support Case

Honestly I am a bit angry about this because I wanted to upgrade to pro (and paid plan) because of the notification that the old platform will disappear by Jan 31st 2018.
My app is perfectly working (and in production) in the old platform without any issue, but whenever I want to migrate it to ionic Pro I get this error.
This means I have to migrate my app while installed at my customers, which I don’t like at all…
I think the same app with the same codebase should work on both the old and new platform, disregarding the payment plan you are on

Don’t tell us, tell that to Ionic. We can’t do a thing about it.

(If you want to upgrade to a paid plan anyway, maybe just do it now to get proper support?)

Can you create a new project with ionic start blank blank and see if you can build this? Then we know it is something wrong with your specific project.

I already contacted support and I have also aKickstarter plan so let’s wait and see what the have to say. The builts started to fail once I migrated from ionic push from cloud services to ionic onesignal since, as you have said the old platform will dissapear soon. So it might be something related to that, when did started to fail in your case? from the beginning?

You should both post your ionic cordova plugin list and compare it.
@racafe You should also run ionic info and post the output so it can be compared to @robrechtvm 's above.

Cordova plugin list

cordova plugin ls
√ Running command - done!
cordova-plugin-add-swift-support 1.6.1 “AddSwiftSupport”
cordova-plugin-camera 2.4.1 “Camera”
cordova-plugin-compat 1.1.0 “Compat”
cordova-plugin-console 1.0.5 “Console”
cordova-plugin-device 1.1.4 “Device”
cordova-plugin-file 4.3.3 “File”
cordova-plugin-file-transfer 1.6.3 “File Transfer”
cordova-plugin-filepath 1.0.2 “FilePath”
cordova-plugin-inappbrowser 1.7.1 “InAppBrowser”
cordova-plugin-ionic 1.1.8 “IonicCordova”
cordova-plugin-splashscreen 4.0.3 “Splashscreen”
cordova-plugin-statusbar 2.2.2 “StatusBar”
cordova-plugin-whitelist 1.3.1 “Whitelist”
cordova-plugin-x-socialsharing 5.1.8 “SocialSharing”
es6-promise-plugin 4.1.0 “Promise”
ionic-plugin-keyboard 2.2.1 “Keyboard”
onesignal-cordova-plugin 2.2.0 “OneSignal Push Notifications”

Ionic info

cli packages: (C:\Users\Rafael Carrion\AppData\Roaming\nvm\v8.4.0\node_modules)

@ionic/cli-utils  : 1.9.2
ionic (Ionic CLI) : 3.9.2

global packages:

Cordova CLI : 7.0.1

local packages:

@ionic/app-scripts : 2.1.4
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.6.0

System:

Android SDK Tools : 26.0.2
Node              : v8.4.0
npm               : 5.3.0
OS                : Windows 10
1 Like

@robrechtvm @Sujan12 I manage to solve the issue. The problem was with the package-lock.json, for some reason after updating node or working with different versions of npm the package-lock.json file ended up corrupted or something and needed to make a fresh install of npm but in order to do that i had to erase node_modules/ folder and also the package-lock.json file. Since I dont have direct access to the uploaded files and folders i added in package.json at the scripts the preinstall action to erase that file and folders, so my package.json looks something like this:

{
“name”: “cuchesApp”,
“version”: “1.0.0”,
“author”: “Technit Solutions”,
“homepage”: “http://technit.com.mx/”,
“private”: true,
“scripts”: {
“preinstall”: “rm -rf node_modules && rm -f package-lock.json”,
“clean”: “ionic-app-scripts clean”,
“build”: “ionic-app-scripts build”,
“lint”: “ionic-app-scripts lint”,
“ionic:build”: “ionic-app-scripts build”,
“ionic:serve”: “ionic-app-scripts serve”
}, …

after that the npm run first remove the file and folders and starts a fresh install of everything.

After that I just added the package-lock.json file to .gitignore

It’s probably a workaround more than a solution but it works, I hope it works for you.

So the node_modules on the Ionic Pro server got corrupted and you added this line to fix this remotely - correct? Whoah!

That is a workaround, but normally this file should really be there as it defines exactly which versions are installed while package.json only specifies ranges of versions.

A post was split to a new topic: Ionic Pro: Failed to parse json