Build dev failed: Cannot read property 'indexOf' of undefined Still having this issue



I am making a brand new project with

ionic start MyProject tabs --ts --v2

cd MyProject serve

=> and I got this error

build dev failed: Cannot read property 'indexOf' of undefined

I have read other threads, but I don’t get where it is coming from. Any help ?

My other ionic projects work perfectly… I don’t understand…


That error is produced for many different reasons, which may be why the threads you have read don’t give you focus. It depends, for example, on the libraries you have loaded. AngularFire2 combined with Firebase has this issue, because of a duplication in their node-modules. If it’s happening with a brand new project, I think the simplest thing is to clean your npm cache and reinstall. You can also run ionic serve --debug and track down what’s causing the issue, but that would make more sense to me if you were getting this error with a project you’ve already worked on.


I clean the chache… Same same…

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'run',
1 verbose cli   'ionic:build',
1 verbose cli   '--' ]
2 info using npm@3.10.9
3 info using node@v6.9.2
4 verbose run-script [ 'preionic:build', 'ionic:build', 'postionic:build' ]
5 info lifecycle ionic-hello-world@~preionic:build: ionic-hello-world@
6 silly lifecycle ionic-hello-world@~preionic:build: no script for preionic:build, continuing
7 info lifecycle ionic-hello-world@~ionic:build: ionic-hello-world@
8 verbose lifecycle ionic-hello-world@~ionic:build: unsafe-perm in lifecycle true
9 verbose lifecycle ionic-hello-world@~ionic:build: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/Users/Stephane/Downloads/MyProject/node_modules/.bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/3.5/bin:/Library/Frameworks/Python.framework/Versions/2.7/bin:/Library/Frameworks/Python.framework/Versions/3.4/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/opt/X11/bin:/usr/local/share/dotnet:/usr/local/git/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands
10 verbose lifecycle ionic-hello-world@~ionic:build: CWD: /Users/Stephane/Downloads/MyProject
11 silly lifecycle ionic-hello-world@~ionic:build: Args: [ '-c', 'ionic-app-scripts build' ]
12 silly lifecycle ionic-hello-world@~ionic:build: Returned: code: 1  signal: null
13 info lifecycle ionic-hello-world@~ionic:build: Failed to exec ionic:build script
14 verbose stack Error: ionic-hello-world@ ionic:build: `ionic-app-scripts build`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:255:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:40:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:877:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:226:5)
15 verbose pkgid ionic-hello-world@
16 verbose cwd /Users/Stephane/Downloads/MyProject
17 error Darwin 15.6.0
18 error argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "ionic:build" "--"
19 error node v6.9.2
20 error npm  v3.10.9
21 error code ELIFECYCLE
22 error ionic-hello-world@ ionic:build: `ionic-app-scripts build`
22 error Exit status 1
23 error Failed at the ionic-hello-world@ ionic:build script 'ionic-app-scripts build'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the ionic-hello-world package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     ionic-app-scripts build
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs ionic-hello-world
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls ionic-hello-world
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]