Error: Cannot find module 'bplist-parser'


#1

I’m just trying Ionic for the first time and I keep getting this error:

alex@mypc ~/Trashable/testApp $ sudo ionic build android
[sudo] password for alex:
module.js:340
throw err;
^

Error: Cannot find module 'bplist-parser’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/src/ConfigChanges/ConfigFile.js:20:14)
at Module._compile (module.js:425:26)
at Object.Module._extensions…js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)

when building a test Ionic application for my Android physical device (HTC Sensation, Android 4.03) connected via USB (USB debug is enabled).

The mentioned “bplist-parser” file is actually missing on my system (both in /lib and in /usr/local/lib). Honestly, I do not know how to install it if not using npm.

My system is as follow:

alex@mypc ~/Trashable/testApp $ npm --version
3.5.2
alex@mypc ~/Trashable/testApp $ node --version
v5.1.1
alex@mypc ~/Trashable/testApp $ lsb_release --all
LSB Version: core-2.0-amd64:core-2.0-noarch:core-3.0-amd64:core-3.0-noarch:core-3.1-amd64:core-3.1-noarch:core-3.2-amd64:core-3.2-noarch:core-4.0-amd64:core-4.0-noarch:core-4.1-amd64:core-4.1-noarch:security-4.0-amd64:security-4.0-noarch:security-4.1-amd64:security-4.1-noarch
Distributor ID: LinuxMint
Description: Linux Mint 17.1 Rebecca
Release: 17.1
Codename: rebecca

Cordova is installed, as required:

alex@mypc ~/Trashable/testApp $ sudo npm install -g cordova
/usr/bin/cordova -> /usr/lib/node_modules/cordova/bin/cordova
/usr/lib
└── cordova@5.4.1

(I have a working instance of the official Google Android Studio installed on this Linux Box, as well.)

But, of course, Cordova does not work:

alex@mypc ~/Trashable/testApp $ sudo cordova
module.js:340
throw err;
^

Error: Cannot find module 'bplist-parser’
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:289:25)
at Module.require (module.js:366:17)
at require (module.js:385:17)
at Object. (/usr/local/lib/node_modules/cordova/node_modules/cordova-lib/node_modules/cordova-common/src/ConfigChanges/ConfigFile.js:20:14)
at Module._compile (module.js:425:26)
at Object.Module._extensions…js (module.js:432:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:313:12)
at Module.require (module.js:366:17)
at require (module.js:385:17)

I googled around a little bit and I found and tried a few possible solutions:

  1. cleaning up and reinstalling everything via npm (never removing node_modules by hand, anyway)

  2. upgrading everything via npm

  3. sudo ln -s /usr/local/lib/node_modules/ /lib/node_modules (of course, it does not work because of the missing file…)

  4. issuing the required installation commands with sudo or as a normal user, with or without the “-g” key (global install).

No way…

Any suggestion?


Impossible to get Ionic running
#2

I am having the same issue and noticed it was reported already here. Are you still having this issue or have you found a resolution?


#3

I just fixed it. To do so, I had to remove all of the installed software using npm and manually remove the node_modules directory. After a clean re-installation from a pristine state, it started working (almost…).

It looks like you have to remove the node_modules directory by hand because npm does not remove it and it does not correctly install all of the required software from scratch if it find an existing node_modules directory on your hard disk.

Now, I’m dealing with a path-related error raised by Apache Cordova:

$ sudo ionic run android

ERROR: Error: Failed to find 'ANDROID_HOME' environment variable. Try setting setting it manually.
Failed to find 'android' command in your 'PATH'. Try update your 'PATH' to include path to valid SDK directory.

Please note that:

$ sudo echo $ANDROID_HOME
/home/alex/Android/Sdk

$ sudo which android
$ (empty string)

$ which android
/home/alex/Android/Sdk/tools/android

All of my PATH variables are defined in my bash.bashrc file (that Linux silently inserts into the .bashrc of every user when he/she launches a bash shell) as follows:

export ANDROID_HOME="/home/alex/Android/Sdk"
export PATH=$PATH:/home/alex/Android/Sdk:/home/alex/.android
export PATH=$PATH:/home/alex/Android/Sdk/tools:/home/alex/Android/Sdk/platform-tools

As long as I can see, this new error is due to the fact that I have Android Studio installed as a regular user (alex) and Apache Cordova/Ionic Framework installed as super-user with sudo. I have no idea on how to fix it, at this moment…


#4

Just to let other people know how it ended: I gave up.

I tried to reinstall all of the packages (node, npm, cordova and ionic) a few different times, following the procedures suggested by a few different bloggers. No way.

Cordova still does not work on my Linux Box and Ionic cannot build any app for Android.

Ionic and Cordova still complain about missing files and insufficient permission but… no matter how you set the permissions and how you install the required files this problem does not get fixed.

The best resource/help I was able to find was this one: https://blog.nraboy.com/2014/09/install-android-cordova-ionic-framework-ubuntu/ (and a few questions/answers at stackoverflow.com).

I think other people should try the installer shell script created by Nic Raboy and should follow his suggestions. They worked very well in most cases.

I will try again as soon I will have another PC available (or as soon as I will upgrade this one with a fresh install of a new Linux distro).


#5

I got the same error. I fixed it by installing missing components manually.

sudo npm install -g bplist-parser
sudo npm install -g minimatch
sudo npm install -g inherits
sudo npm install -g path-is-absolute
sudo npm install -g inflight
sudo npm install -g once


#6

Even easier way (which worked for me) was to just to use sudo npm update -g. It seemed to have installed all missing modules. i found this solution on the spanish phonegap forum for those who are curious.


#7

Thanks a lot for this… Worked like a charm…


#8

Just in general its a really bad idea to install dependencies like that with sudo, you shouldn’t need sudo for anything other than installing npm itself. If you do you can end up with a lot of weird errors and conflicts.

You can use this to change the npm ownership status or this command : sudo chown -R $(whoami) ~/.npm.


#9

this work for me, but i just sudo npm install -g bplist-parser and its work… thanks


#10

I had a similar dependency hell, but i managed to fix it by running “sudo npm update -g” about 4 times which seemed to sort out all the dependencies.