Npm start give error when trying to run ionic project

I am trying to run ionic application in mac os but when I run

npm start

I am getting this error

0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli   '/Users/amira/.nvm/versions/node/v14.15.0/bin/node',
1 verbose cli   '/Users/amira/.nvm/versions/node/v14.15.0/bin/npm',
1 verbose cli   'run',
1 verbose cli   'ionic:serve',
1 verbose cli   '--',
1 verbose cli   '--host=localhost',
1 verbose cli   '--port=8100'
1 verbose cli ]
2 info using npm@6.14.8
3 info using node@v14.15.0
4 verbose run-script [ 'preionic:serve', 'ionic:serve', 'postionic:serve' ]
5 info lifecycle moodlemobile@4.1.0~preionic:serve: moodlemobile@4.1.0
6 info lifecycle moodlemobile@4.1.0~ionic:serve: moodlemobile@4.1.0
7 verbose lifecycle moodlemobile@4.1.0~ionic:serve: unsafe-perm in lifecycle true
8 verbose lifecycle moodlemobile@4.1.0~ionic:serve: PATH: /Users/amira/.nvm/versions/node/v14.15.0/lib/node_modules/npm/node_modules/npm-lifecycle/node-gyp-bin:/Users/amira/Data/asu-mobile/moodleapp3/node_modules/.bin:/Users/amira/Data/asu-mobile/moodleapp3/node_modules/.bin:/Users/amira/.nvm/versions/node/v14.15.0/bin:/opt/anaconda3/bin:/opt/anaconda3/condabin:/usr/local/sbin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Applications/VMware Fusion.app/Contents/Public:/usr/local/share/dotnet:/Users/amira/.dotnet/tools:/Library/Apple/usr/bin:/Library/Frameworks/Mono.framework/Versions/Current/Commands:/Applications/Xamarin Workbooks.app/Contents/SharedSupport/path-bin
9 verbose lifecycle moodlemobile@4.1.0~ionic:serve: CWD: /Users/amira/Data/asu-mobile/moodleapp3
10 silly lifecycle moodlemobile@4.1.0~ionic:serve: Args: [
10 silly lifecycle   '-c',
10 silly lifecycle   'cross-env-shell ./scripts/serve.sh "--host=localhost" "--port=8100"'
10 silly lifecycle ]
11 silly lifecycle moodlemobile@4.1.0~ionic:serve: Returned: code: 126  signal: null
12 info lifecycle moodlemobile@4.1.0~ionic:serve: Failed to exec ionic:serve script
13 verbose stack Error: moodlemobile@4.1.0 ionic:serve: `cross-env-shell ./scripts/serve.sh "--host=localhost" "--port=8100"`
13 verbose stack Exit status 126
13 verbose stack     at EventEmitter.<anonymous> (/Users/amira/.nvm/versions/node/v14.15.0/lib/node_modules/npm/node_modules/npm-lifecycle/index.js:332:16)
13 verbose stack     at EventEmitter.emit (events.js:315:20)
13 verbose stack     at ChildProcess.<anonymous> (/Users/amira/.nvm/versions/node/v14.15.0/lib/node_modules/npm/node_modules/npm-lifecycle/lib/spawn.js:55:14)
13 verbose stack     at ChildProcess.emit (events.js:315:20)
13 verbose stack     at maybeClose (internal/child_process.js:1048:16)
13 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid moodlemobile@4.1.0
15 verbose cwd /Users/amira/Data/asu-mobile/moodleapp3
16 verbose Darwin 22.3.0
17 verbose argv "/Users/amira/.nvm/versions/node/v14.15.0/bin/node" "/Users/amira/.nvm/versions/node/v14.15.0/bin/npm" "run" "ionic:serve" "--" "--host=localhost" "--port=8100"
18 verbose node v14.15.0
19 verbose npm  v6.14.8
20 error code ELIFECYCLE
21 error errno 126
22 error moodlemobile@4.1.0 ionic:serve: `cross-env-shell ./scripts/serve.sh "--host=localhost" "--port=8100"`
22 error Exit status 126
23 error Failed at the moodlemobile@4.1.0 ionic:serve script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 126, true ]

This is the content of serve.sh file

#!/bin/bash

# This script is necessary because @ionic/cli is passing one argument to the ionic:serve hook
# that is unsupported by angular cli: https://github.com/ionic-team/ionic-cli/issues/4743
#
# Once the issue is fixed, this script can be replaced adding the following npm script:
#
#     "ionic:serve": "gulp watch & NODE_OPTIONS=--max-old-space-size=4096 ng serve"
#

# Run gulp watch.
echo "> gulp watch &"
gulp watch &

# Remove unknown arguments and prepare angular target.
args=("$@")
angulartarget="serve"
total=${#args[@]}
for ((i=0; i<total; ++i)); do
    case ${args[i]} in
        --project=*)
            unset args[i];
            ;;
        --platform=*)
            angulartarget="ionic-cordova-serve";
            ;;
    esac
done

# Serve app.
echo "> NODE_OPTIONS=--max-old-space-size=4096 ng run app:$angulartarget ${args[@]}"
NODE_OPTIONS=--max-old-space-size=4096 ng run "app:$angulartarget" ${args[@]}

I am following this tutorial : Setting up your development environment for the Moodle App | Moodle Developer Resources

can anyone please tell me what is the problem ?

Hi @amiraelsayed unfortunately I can’t give you an answer, but I’m having the same issue… If you managed to solve it, can you tell me how did you do it? Thank you!