4

I was trying to build Moodle's ionic mobile app locally on Windows by following the below steps:

cd project-directory

ionic platform add android

The command prompt returns the below error:

Updated the hooks directory to have execute permissions
Adding android project...
Running command: cmd "/s /c "C:\Users\zameer\.cordova\lib\npm_cache\cordova-andr
oid\4.1.1\package\bin\create.bat D:\ionic\moodlemobile2-master\moodlemobile2-mas
ter\platforms\android com.moodle.moodlemobile "Moodle Mobile" --cli""
Creating Cordova project for the Android platform:
        Path: platforms\android
        Package: com.moodle.moodlemobile
        Name: Moodle Mobile
        Activity: MainActivity
        Android target: android-22
Copying template files...
Android project created with [email protected]
Running command: "C:\Program Files\nodejs\node.exe" D:\ionic\moodlemobile2-maste
r\moodlemobile2-master\hooks\after_prepare\010_add_platform_class.js D:\ionic\mo
odlemobile2-master\moodlemobile2-master
add to body class: platform-android
Running command: "C:\Program Files\nodejs\node.exe" D:\ionic\moodlemobile2-maste
r\moodlemobile2-master\hooks\after_prepare\020_add_ios_transport_security.js D:\
ionic\moodlemobile2-master\moodlemobile2-master
module.js:338
    throw err;
          ^
Error: Cannot find module 'plist'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.Module._load (module.js:278:25)
    at Module.require (module.js:365:17)
    at require (module.js:384:17)
    at Object. (D:\ionic\moodlemobile2-master\moodlemobile2-master\ho
oks\after_prepare\020_add_ios_transport_security.js:10:13)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
Error: Hook failed with error code 1: D:\ionic\moodlemobile2-master\moodlemobile
2-master\hooks\after_prepare\020_add_ios_transport_security.js

Everything seems normal till the below part of the above error block:

throw err;
      ^
Error: Cannot find module 'plist'

My aim is to run this project locally to see ionic in action

What is this plist module? Why is it not getting detected?

2 Answers 2

9

After cloning a Git repository that contains a Ionic app, you need to run these 2 additional commands:

Install Node.js dependencies

npm install

It will install all the Node.js dependencies in the local node_modules folder. The modules considered are the ones listed under dependencies and devDependencies in the package.json file located at the root of the cloned Git repository.

Install Cordova plugins

ionic state restore

This command looks at the cordovaPlugins and cordovaPlatforms attributes in the package.json file and install the additional platforms and plugins code required for the app.

Sign up to request clarification or add additional context in comments.

5 Comments

npm install or npm install -g ionic? Because this command on the official website is not matching
If you already installed Ionic with -g (globally) you should not need to reinstall it. 'npm install' is to install the app dependencies
In my case, I had to also create an empty ./www folder in the root of the repo to avoid this error.
This solution is really good. I even reinstalled npm because of dependency issues. never knew that I have to do this for cloned git repos
I have executed "ionic cordova prepare" command on iOS because of message "ionic state" has been removed
2

You did not execute npm install so you are missing the required packages.

Read this on what need to be done to work with ionic.

Go into the project folder where the package.json is in and execute the npm install form that folder.

3 Comments

ionic is already installed. Do we need to re-install ionic for every new project?
ionic is installed globally on the machine but the packages should be in all your projects. so you will need to install dependencies per project. checkout to see if you have the nde_modules folder
@arainone Let me start again. I'll get back after trying this. Thanks to both of you!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.