0

I was following this tutorial: https://ccoenraets.github.io/cordova-tutorial/data-storage.html

It is my first cordova application.

When I typed

npm install

I got this:

npm ERR! install Couldn't read dependencies
npm ERR! package.json ENOENT, open '/home/nicki/code/cordova/hello/package.json'
npm ERR! package.json This is most likely not a problem with npm itself.
npm ERR! package.json npm can't find a package.json file in your current directory.

npm ERR! System Linux 3.13.0-24-generic
npm ERR! command "/usr/bin/node" "/usr/bin/npm" "install"
npm ERR! cwd /home/nicki/code/cordova/hello
npm ERR! node -v v0.10.37
npm ERR! npm -v 1.4.28
npm ERR! path /home/nicki/code/cordova/hello/package.json
npm ERR! code ENOPACKAGEJSON
npm ERR! errno 34
npm ERR! 
npm ERR! Additional logging details can be found in:
npm ERR!     /home/nicki/code/cordova/hello/npm-debug.log
npm ERR! not ok code 0

So I cd to my directory where package.json is present, I did

cd platforms/browser/cordova/node_modules/cordova-serv

And found package.json which has following:

{
  "name": "cordova-serve",
  "version": "0.1.2",
  "description": "Apache Cordova server support for cordova-lib and cordova-browser.",
  "main": "serve.js",
  "repository": {
    "type": "git",
    "url": "git://git-wip-us.apache.org/repos/asf/cordova-lib.git"
  },
  "keywords": [
    "cordova",
    "server",
    "apache"
  ],
  "author": {
    "name": "Apache Software Foundation"
  },
  "license": "Apache-2.0",
  "bugs": {
    "url": "https://issues.apache.org/jira/browse/CB",
    "email": "dev@cordova.apache.org"
  },
  "dependencies": {
    "combined-stream": "^1.0.3",
    "d8": "^0.4.4",
    "mime": "^1.2.11",
    "q": "^1.4.1",
    "shelljs": "^0.5.1"
  },
  "devDependencies": {
    "jshint": "^2.8.0"
  },
  "scripts": {
    "jshint": "node node_modules/jshint/bin/jshint src"
  },
  "engines": {
    "node": ">= 0.12.0",
    "npm": ">= 2.5.1"
  },
  "_id": "cordova-serve@0.1.2",
  "_shasum": "79225e85f6085c811baf7b4993bf2b6ae5720ee2",
  "_resolved": "https://registry.npmjs.org/cordova-serve/-/cordova-serve-0.1.2.tgz",
  "_from": "cordova-serve@>=0.1.1 <0.2.0",
  "_npmVersion": "2.7.4",
  "_nodeVersion": "0.12.2",
  "_npmUser": {
    "name": "timbarham",
    "email": "npmjs@barhams.info"
  },
  "dist": {
    "shasum": "79225e85f6085c811baf7b4993bf2b6ae5720ee2",
    "tarball": "http://registry.npmjs.org/cordova-serve/-/cordova-serve-0.1.2.tgz"
  },
  "maintainers": [
    {
      "name": "timbarham",
      "email": "npmjs@barhams.info"
    }
  ],
  "directories": {},
  "readme": "ERROR: No README data found!"
}

Then I did:

sudo npm install

And it installed everything without errors.

Then I did node server again and it gave me same error again:

module.js:340
    throw err;
          ^
Error: Cannot find module '/home/nicki/code/cordova/hello/platforms/browser/cordova/node_modules/cordova-serve/server'
    at Function.Module._resolveFilename (module.js:338:15)
    at Function.Module._load (module.js:280:25)
    at Function.Module.runMain (module.js:497:10)
    at startup (node.js:119:16)
    at node.js:935:3

I tried command node server from many other directories (like node_modules, main application directory, etc), and it still didn't work. Any suggestions?

user1735921
  • 1,359
  • 1
  • 21
  • 46

1 Answers1

0

I think you are in some wrong folder. The tutorial says you have to get the files that are located here: https://github.com/ccoenraets/cordova-tutorial

The step you are on you have to go inside the server folder cd server ( https://github.com/ccoenraets/cordova-tutorial/tree/master/server ) And run npm install from there and then npm server like this you will start the server that is in that directory

DevAlien
  • 2,456
  • 15
  • 17