Getting started -> Simplest possible app ERROR?????

303 views
Skip to first unread message

lodopidolo

unread,
Jul 23, 2012, 10:54:21 AM7/23/12
to ka...@googlegroups.com
Hello, I'm introducing in Kanso, so I've begun with Getting started -> Simplest possible app, but when I make the Third party modules exercise ( http://kan.so/docs/Third-party_modules ), I've got an error due to jquery:

Reading dependency tree...
loading .
preprocessor attachments/add
preprocessor modules/add
preprocessor properties/queue
loading packages/attachments
loading packages/modules
loading packages/properties
loading packages/db
loading packages/underscore
loading packages/events
Error: Error when running preprocessor: "attachments/add"
Error: ENOENT, stat '~/Desarrollo/kanso/example-app/jquery.js'
Failed

I've tryed with this kanso.json:

{
    "name": "example-app",
    "version": "0.0.1",
    "description": "The simplest possible app",
    "attachments": ["index.html", "jquery.js"],
    "modules": ["lib"],
    "load": "lib/app",
    "dependencies": {
        "attachments": null,
        "modules": null,
        "properties": null,
        "db": null,
        "jquery": null
    }
}

but I've got errors too.


Milan Andric

unread,
Jul 23, 2012, 11:11:26 AM7/23/12
to ka...@googlegroups.com
Andres, it should work if you remove the 'jquery' dependency in the kanso.json.  

Or you can run `kanso install` to fetch the jquery package and install it locally but that is a different tutorial/excercise. ;)

--
Milan

Andrés Orencio

unread,
Jul 23, 2012, 1:06:04 PM7/23/12
to ka...@googlegroups.com
If I follow the exercise:

This is the actual folder structure:

$ find ./ -maxdepth 2 -type d 
./
./data
./lib
./packages
./packages/modules
./packages/underscore
./packages/attachments
./packages/events
./packages/properties
./packages/db

The kanso.json file:

$ cat kanso.json 
{
    "name": "example-app",
    "version": "0.0.1",
    "description": "The simplest possible app",
    "attachments": ["index.html", "jquery.js"],
    "modules": ["lib"],
    "load": "lib/app",
    "dependencies": {
        "attachments": null,
        "modules": null,
        "properties": null,
        "db": null
    }
}

Deploying:

$ kanso install
installing from directory .
Building version tree...
OK
Reading dependency tree...
loading .
preprocessor attachments/add
preprocessor modules/add
preprocessor properties/queue
loading packages/attachments
loading packages/modules
loading packages/properties
loading packages/db
loading packages/underscore
loading packages/events
Error: Error when running preprocessor: "attachments/add"
Error: ENOENT, stat '~/Desarrollo/kanso/example-app/jquery.js'
Failed

I add jquery dependecy:

$ cat kanso.json 
{
    "name": "example-app",
    "version": "0.0.1",
    "description": "The simplest possible app",
    "attachments": ["index.html", "jquery.js"],
    "modules": ["lib"],
    "load": "lib/app",
    "dependencies": {
        "attachments": null,
        "modules": null,
        "properties": null,
        "db": null,
        "jquery": null
    }
}

Install and deploy:

$ kanso install
installing from directory .
Building version tree...
checking jquery
installing jqu...@2.0.0 (cached)
OK
Reading dependency tree...
loading .
preprocessor attachments/add
preprocessor modules/add
preprocessor properties/queue
loading packages/attachments
loading packages/modules
loading packages/properties
loading packages/db
loading packages/jquery
loading packages/underscore
loading packages/events
Error: Error when running preprocessor: "attachments/add"
Error: ENOENT, stat '~/Desarrollo/kanso/example-app/jquery.js'
Failed

What occurs?





2012/7/23 Milan Andric <mi...@medicmobile.org>

Milan Andric

unread,
Jul 23, 2012, 4:55:26 PM7/23/12
to ka...@googlegroups.com
The attachments module dies when it can't find jquery.js.  If you either add jquery.js to the current directory or remove it from the "attachments" property in kanso.json the project should build.

There is a difference between an attachment and a module. An attachment is simply uploaded to couchdb using the attachments API while a package/module is made available on the backend and frontend as a commonjs module.

HTH,

Milan

Andrés Orencio

unread,
Jul 24, 2012, 4:02:54 AM7/24/12
to ka...@googlegroups.com
Hello Milan, I've removed jquery.js from attachments but mantained it in dependencies:

$ cat kanso.json
{
    "name": "example-app",
    "version": "0.0.1",
    "description": "The simplest possible app",
    "attachments": ["index.html"],
    "modules": ["lib"],
    "load": "lib/app",
    "dependencies": {
        "attachments": null,
        "modules": null,
        "properties": null,
        "db": null,
"jquery": null
    }
}
kanso install
installing from directory .
Building version tree...
OK
~/Desarrollo/kanso/example-app$ kanso push http://localhost:5984/example
Reading dependency tree...
loading .
preprocessor attachments/add
preprocessor modules/add
preprocessor properties/queue
loading packages/attachments
loading packages/modules
loading packages/properties
loading packages/db
loading packages/jquery
loading packages/underscore
loading packages/events
postprocessor attachments/cleanup
postprocessor modules/attachment
postprocessor properties/load
postprocessor modules/cleanup
Build complete: 513ms
Uploading...

But when I execute the aplication doesn't run:

Resolviendo localhost (localhost)... 127.0.0.1
Conectando con localhost (localhost)[127.0.0.1]:5984... conectado.
Petición HTTP enviada, esperando respuesta... 404 Object Not Found
2012-07-24 09:43:18 ERROR 404: Object Not Found.

I've added it as module:

$ cat kanso.json
{
    "name": "example-app",
    "version": "0.0.1",
    "description": "The simplest possible app",
    "attachments": ["index.html"],
    "modules": ["lib", "packages/jquery"],
    "load": "lib/app",
    "dependencies": {
        "attachments": null,
        "modules": null,
        "properties": null,
        "db": null,
"jquery": null
    }
}
$ kanso install
installing from directory .
Building version tree...
OK
~/Desarrollo/kanso/example-app$ kanso push http://localhost:5984/example
Reading dependency tree...
loading .
preprocessor attachments/add
preprocessor modules/add
preprocessor properties/queue
loading packages/attachments
loading packages/modules
loading packages/properties
loading packages/db
loading packages/jquery
loading packages/underscore
loading packages/events
postprocessor attachments/cleanup
postprocessor modules/attachment
postprocessor properties/load
postprocessor modules/cleanup
Build complete: 152ms
Uploading...
Resolviendo localhost (localhost)... 127.0.0.1
Conectando con localhost (localhost)[127.0.0.1]:5984... conectado.
Petición HTTP enviada, esperando respuesta... 404 Object Not Found
2012-07-24 09:45:22 ERROR 404: Object Not Found.

I think kanso resolve all dependencies. If I have added jquery in dependencis, kanso must download it. It is ok, jquery is downloaded. But it isn't available as conventional path.

In the example:

<h1>
Hello, world!</h1>
<ul id="makes">
</ul>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="modules.js">
</script>
<script type="text/javascript">
var db = require('db').current();
db.getView('example-app', 'makes', function (err, data) {
if (err) {
// an error occurred
return
alert(err);
}
for (var i = 0; i < data.rows.length; i++) {
$('<li/>').text(data.rows[i].key).appendTo('#makes');
}
});
</script>

jquery.js is not available like module.js, and both are specified to kanso in the same form.

So, what is the problem?
jQuery can not be treated as dependency and must be download separately and load with module/load?

Thanks.




2012/7/23 Milan Andric <mi...@medicmobile.org>

Milan Andric

unread,
Jul 24, 2012, 9:33:06 AM7/24/12
to ka...@googlegroups.com
Hi Andres, comments below…

This is the correct behavior because jquery.js does not exist as an attachment.  If you want to create /jquery.js as a static resource then you should just download jquery and create a jquery.js next to your index.html and remove it from dependencies list in kanso.json.  That probably follows along with the getting started tutorial better and gets you up and running.
This is by design, it's not available as a conventional path but you can use require to import the library now.  


In the example:

<h1>
Hello, world!</h1>
<ul id="makes">
</ul>
<script type="text/javascript" src="jquery.js">
</script>
<script type="text/javascript" src="modules.js">
</script>
<script type="text/javascript">
var db = require('db').current();
db.getView('example-app', 'makes', function (err, data) {
if (err) {
// an error occurred
return
alert(err);
}
for (var i = 0; i < data.rows.length; i++) {
$('<li/>').text(data.rows[i].key).appendTo('#makes');
}
});
</script>

jquery.js is not available like module.js, and both are specified to kanso in the same form.

Right, modules.js is created by kanso and uses require to provide an interface for your libraries.   Including the jquery.js package dependency in kanso.json does not create a static resource, instead it provides the library in your modules.js (frontend) and on your couchdb design doc (backend).  You should take a peek in there.  This is a better way to deal with js libraries but might be confusing you right now until you get more familiar with the tool.  But if you remove the jquery script tag and instead do var $ = require('jquery'); inside of your application code it should give you a reference to the jquery object.


So, what is the problem?
jQuery can not be treated as dependency and must be download separately and load with module/load?

Thanks.

HTH,

Milan

Andrés Orencio

unread,
Jul 25, 2012, 4:16:04 AM7/25/12
to ka...@googlegroups.com
Thank you very much Milan for your patience and explanations. It is solved like you say:

<!-- <script type="text/javascript" src="jquery.js"></script> -->
<script type="text/javascript">
    var $ = require('jquery');
    var db = require('db').current();
...

and kanso.json:

{
    "name": "example-app",
    "version": "0.0.1",
    "description": "The simplest possible app",
    "attachments": ["index.html"],
    "modules": ["lib"],
    "load": "lib/app",
    "dependencies": {
        "attachments": null,
        "modules": null,
        "properties": null,
        "db": null,
"jquery": null
    }
}
I've modified http://kan.so/docs/Third-party_modules with this changes.



2012/7/24 Milan Andric <mi...@medicmobile.org>

Milan Andric

unread,
Jul 25, 2012, 9:02:02 AM7/25/12
to ka...@googlegroups.com
Andres, in the wiki page we should  remove  jquery.js from the attachments property in kanso.json then. 

Andrés Orencio

unread,
Jul 26, 2012, 7:23:42 AM7/26/12
to ka...@googlegroups.com
Jeje, excuse me. I've already removed in the wiki.


2012/7/25 Milan Andric <mi...@medicmobile.org>

Milan Andric

unread,
Jul 26, 2012, 1:52:29 PM7/26/12
to ka...@googlegroups.com
Thanks Andrés!
Reply all
Reply to author
Forward
0 new messages