Ionic Pro: Build Failed "missing script: build"

have you created a blank app or what ?!

He has created a v2 app by the looks of it.

I didn’t work with ionic v2 before, so unfortunately I can’t help him :sweat_smile:

Ionic Pro is a hosted and closed source service, so there is not much we, the community, can help you with, sorry. Check these:

You can - and should - contact support at http://ionicframework.com/support#support

The v1 problem is in the FAQ: https://ionic.zendesk.com/hc/en-us/articles/115012944328-Failed-build-on-Ionic-1-app-Missing-build-script

I think with my version, I’m supposed to use the build script that is already there. I just don’t know why it won’t work.

I have the same problem.
In the package.json file

“Scripts”: {
“Build”: “ls”
}

After revision, I tried bulid again

Build failed: No www / directory detected

I get the above error.

How can I solve it?
I want a detailed explanation.

i solve the problem of “No www/ directory detected” adding the folder “www” to GIT with “git add www/* -f” and now is working on ionic view

I also solved the no www/ directory using "git add www/* -f. Now the build completes successfully. But one thing I don’t understand. In the build log it says:
Fetching build dependencies…
Detected www/ directory commited to version control. Assuming Ionic 1 app.

I am not running an Ionic 1 app so I don’t understand why the build assumes that. Any thoughts?

1 Like

Because you committed www to version control with git add www/*. That’s what the message tells you.

Ok I had similar issue which received the message:
Make sure your project has a build script in the package.json” in the end.

But in my case I also of some unknown reason also get follow issue :
“Cannot find module” which was a very odd problem. Everything was working when doing this on my machine but not on dashboard.ionicjs.com/
throw theirs cloud service when attaching/adding new “providers”.

Now it turns out that there wasn’t any error. It was just
that the whole thing could easily be solved
when just type:

git add www/* -f

And also remove the directory from .gitignore file where it says
www/

And then when typing
npm run build --build
everything works perfectly!

Not sure why this is working.

This is the setup I got so far:

git version 2.14.2
typescript : 2.3.4 (even work with 2.5.3)
app-ionic-script : 3.0.0. (even work with 2.4.1)

cli packages:

    @ionic/cli-utils  : 1.13.0
    ionic (Ionic CLI) : 3.13.0

global packages:

    cordova (Cordova CLI) : 7.0.1 

local packages:

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

System:

    Android SDK Tools : 25.2.5
    ios-deploy        : 1.9.1 
    Node              : v6.7.0
    npm               : 3.10.8 
    OS                : macOS Sierra
    Xcode             : Xcode 8.3.3 Build version 8E3004b 

Misc:

    backend : pro

Not sure if this could be call issue, but how do I do the same without including www directory everytime ?

1 Like

I found that my gitignore blocked all the important files being pushed to ionic pro, make sure you push all the files by checking your gitignore

Hey All,
I’m one of the developers working on Ionic Pro and I saw this thread and wanted to jump in to clarify what is going on here. When you push your code to Ionic Pro it attempts to do a build of your project by installing the dependencies in your package.json file and then doing npm run build Here are the npm docs on build and here is a blog describing ways of using npm build. You can modify the build script to do whatever you like in order to customize the build of your app. This can be done for either an Ionic v1 and Ionic 2+ apps. Ionic Pro simply expects 2 things:

  1. You have a build script in your package.json*

  2. That the output of your build (your built app) is put into the www directory

The * for requirement 1 is that most Ionic 1 apps don’t have a build process and for Ionic 1 apps we recommended that the www directory be committed to version control. We decided that rather than to fail if npm run build failed we would first check if you’ve committed a www directory to version control. If you have we assume it is an Ionic v1 app and we attempt a build (some Ionic v1 developers had a build process) but if it fails we just treat the contents of the www as your app and save that.

If you see the error Build failed: No www / directory detected that is meant to inform you that your build process didn’t generate a www directory as we expected. If you simply add the www directory to version control it will assume it is an Ionic v1 app and it will succeed however it won’t be building the app from your source code unless your build script is configured to do so. Essentially you’ll just be pushing whatever you’ve built and committed locally.

We’re currently working on some features to make the build process more intuitive and customizable but what I describe above is the way it currently works. Hope that helps clarify things a little for folks.

–Nick

2 Likes

I started a new app with tabs template and deploy on my dashboard was great, but after creating two new pages and uploading the deploy failed, I need help.

Running with gitlab-ci-multi-runner 9.1.0 (0118d89)
on Prod Snapshot Builds 1 (c9648220)
Using Shell executor…
Running on ip-10-2-65-187…
Cloning repository…
Cloning into ‘/home/gitlab-runner/builds/c9648220/0/project-1’…
Checking out 3cc794ac as master…
Skipping Git submodules setup
$ fetch-updates
Checking for build process updates…
$ build-app
Fetching build dependencies…
Running: npm install
npm WARN deprecated object-keys@0.2.0: Please update to the latest object-keys

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
npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@1.1.2 (node_modules/fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@1.1.2: wanted {“os”:“darwin”,“arch”:“any”} (current: {“os”:“linux”,“arch”:“x64”})

added 719 packages in 23.18s
npm install succeeded
Running: 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 Never@0.0.1~prebuild: Never@0.0.1
npm info lifecycle Never@0.0.1~build: Never@0.0.1

Never@0.0.1 build /usr/src/app
ionic-app-scripts build

[00:43:56] ionic-app-scripts 3.0.1
[00:43:56] build dev started …
[00:43:56] clean started …
[00:43:56] clean finished in 1 ms
[00:43:56] copy started …
[00:43:57] deeplinks started …
[00:43:57] deeplinks finished in 33 ms
[00:43:57] transpile started …
[00:43:59] typescript: src/app/app.module.ts, line: 10
Cannot find module ‘…/pages/me/me’.

   L9:  import { TabsPage } from '../pages/tabs/tabs';
  L10:  import {MePage} from '../pages/me/me';

[00:43:59] typescript: src/app/app.module.ts, line: 11
L11: import { SettingsPage} from ‘…/pages/settings/settings’;

        Cannot find module '../pages/settings/settings'. 

[00:43:59] typescript: src/pages/tabs/tabs.ts, line: 6
L10: import {MePage} from ‘…/pages/me/me’;
L11: import { SettingsPage} from ‘…/pages/settings/settings’;

        Cannot find module '../me/me'. 

   L5:  import { HomePage } from '../home/home';
   L6:  import {MePage} from '../me/me';
   L7:  import {SettingsPage} from '../settings/settings';

[00:43:59] typescript: src/pages/tabs/tabs.ts, line: 7
Cannot find module ‘…/settings/settings’.

   L6:  import {MePage} from '../me/me';
   L7:  import {SettingsPage} from '../settings/settings';

[00:43:59] ionic-app-script task: “build”
[00:43:59] Error: Failed to transpile program
Error: Failed to transpile program
at new BuildError (/usr/src/app/node_modules/@ionic/app-scripts/dist/util/errors.js:16:28)
at /usr/src/app/node_modules/@ionic/app-scripts/dist/transpile.js:159:20
at Promise ()
at transpileWorker (/usr/src/app/node_modules/@ionic/app-scripts/dist/transpile.js:107:12)
at Object.transpile (/usr/src/app/node_modules/@ionic/app-scripts/dist/transpile.js:64:12)
at /usr/src/app/node_modules/@ionic/app-scripts/dist/build.js:106:82
at
npm info lifecycle Never@0.0.1~build: Failed to exec build script
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! Never@0.0.1 build: ionic-app-scripts build
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the Never@0.0.1 build script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.

npm ERR! A complete log of this run can be found in:
npm ERR! /home/gitlab-runner/.npm/_logs/2017-10-31T00_43_59_746Z-debug.log
npm run build failed
Make sure your project has a build script in the package.json
Running after script…
$ clean-up
Cleaning up files…
Successful clean up
ERROR: Job failed: exit status 1

Having this issue migrating to ionic Pro with a v2 project. I have a build script and build is in www directory, but build failing with same error on ionic pro. :confused:

Solution (for me):

npm install @ionic/app-scripts@latest --save-dev
npm install @angular/tsc-wrapped autoprefixer --save
1 Like

I tried your solution but didnt work.

I found a solution to my problem.

$sudo git status

then will show the Untracked files:

just do this

$sudo git add src/pages/settings/

if you type
$sudo git status

will show

On branch master
Changes to be committed:
(use “git reset HEAD …” to unstage)

new file:   src/pages/settings/settings.html
new file:   src/pages/settings/settings.module.ts
new file:   src/pages/settings/settings.scss
new file:   src/pages/settings/settings.ts

then type
$sudo git commit -m ‘your new’

will show

[master b8bb30b] fast
4 files changed, 58 insertions(+)
create mode 100644 src/pages/settings/settings.html
create mode 100644 src/pages/settings/settings.module.ts
create mode 100644 src/pages/settings/settings.scss
create mode 100644 src/pages/settings/settings.ts

finally type this

$sudo git push ionic master
that worked for me.

1 Like

Thank you it worked for me

Thank you, new files that need to be added were un-tracked by git in my case. Once they were added, everything worked.

Same issue on an Ionic 3 projet. I just updated my package.json as follow :

  "scripts": {
    "build": "ionic-app-scripts build",
    "ionic:build": "ionic-app-scripts build",
    "ionic:serve": "ionic-app-scripts serve"
  },
1 Like