我正在关注本教程: https://ccoenraets.github.io/cordova-tutorial/data-storage.html
这是我的第一个cordova应用程序。
当我输入
时npm install
我明白了:
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
所以我cd到我的package.json所在的目录,我做了
cd platforms/browser/cordova/node_modules/cordova-serv
找到了包含以下内容的package.json:
{
"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!"
}
然后我做了:
sudo npm install
它安装了所有内容而没有错误。
然后我再次node server
再次给了我同样的错误:
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
我尝试从许多其他目录(如node_modules,主应用程序目录等)中命令node server
,但它仍然无法正常工作。
有什么建议吗?
答案 0 :(得分:0)
我认为你在错误的文件夹中。
该教程说您必须获取位于此处的文件:CellFormatting
您所在的步骤必须进入服务器文件夹cd server
(https://github.com/ccoenraets/cordova-tutorial)
然后像这样运行npm install from there
然后npm server
,您将启动该目录中的服务器