PushNotificationSample icon indicating copy to clipboard operation
PushNotificationSample copied to clipboard

Cannot find module '../../package.json'

Open arnthorsnaer opened this issue 9 years ago • 8 comments

Hi there

When I try to add some of the required dependancies, while located at the project root, I get an error about problem finding package.json, it seems to be expecting it in the project root but it is not there.

Am I missing something?

...
Fetching plugin "https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git" via git clone
Running command: /Users/arnthorsnaer/Documents/PushNotificationSample/hooks/after_plugin_add/010_register_plugin.js /Users/arnthorsnaer/Documents/PushNotificationSample

module.js:340
    throw err;
          ^
Error: Cannot find module '../../package.json'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Module.require (module.js:364:17)
    at require (module.js:380:17)
    at Object.<anonymous> (/Users/arnthorsnaer/Documents/PushNotificationSample/hooks/after_plugin_add/010_register_plugin.js:7:19)
    at Module._compile (module.js:456:26)
    at Object.Module._extensions..js (module.js:474:10)
    at Module.load (module.js:356:32)
    at Function.Module._load (module.js:312:12)
    at Function.Module.runMain (module.js:497:10)
Error: Hook failed with error code 8: /Users/arnthorsnaer/Documents/PushNotificationSample/hooks/after_plugin_add/010_register_plugin.js
    at /usr/local/lib/node_modules/cordova/node_modules/cordova-lib/src/hooks/HooksRunner.js:194:23
    at _rejected (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:797:24)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:823:30
    at Promise.when (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:1035:31)
    at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:741:41)
    at /usr/local/lib/node_modules/cordova/node_modules/q/q.js:557:44
    at flush (/usr/local/lib/node_modules/cordova/node_modules/q/q.js:108:17)
    at process._tickCallback (node.js:415:13)

arnthorsnaer avatar Feb 02 '15 22:02 arnthorsnaer

A simple workaround is to create a package.json file in the project root. I'll keep this issue open since you'll probably want to drop in a basic package.json file into this project or edit the README.

arnthorsnaer avatar Feb 02 '15 22:02 arnthorsnaer

I've had the same problem, @hollyschinsky is the package.json a file you use for personal development that didn't make it into the repo?

yanniboi avatar Feb 08 '15 17:02 yanniboi

Hi guys, I used Ionic to create the basic project which contains a package.json file by default. Are you using Ionic as well?

hollyschinsky avatar Feb 10 '15 18:02 hollyschinsky

At least I am. In this instance I did not start with an standard Ionic project though, I started with your sample project. You excluded the package.json when pushing to this repo?

arnthorsnaer avatar Feb 10 '15 18:02 arnthorsnaer

Oh ok, yes, I should have clarified that. I usually recommend creating a starter project with Ionic and then replace the www folder with mine from here.

ionic start myPushApp blank

Then add the dependencies... Then it's not limited to versions of things. Does that make sense?

hollyschinsky avatar Feb 10 '15 18:02 hollyschinsky

Yes, makes sense. Thanks :)

arnthorsnaer avatar Feb 10 '15 18:02 arnthorsnaer

Makes sense - I would recommend adding this to the README :)

chrisabrams avatar Apr 16 '15 15:04 chrisabrams

sudo npm install -g [email protected] use this version of ionic will solve this issue

manjurock avatar Sep 29 '16 09:09 manjurock