0

I want to have a strongloop example only using javascript without angular. There's no complete working example without angular for now. I want to simply include the browser.bundle.js in my index.html, then sync data from/to server side. In fact, I'm trying to replace pouchdb in my program since the couchdb seems not success in open source community.

I can't follow up this document correctly: Running Loopback in the browser

  1. create browser-app.js with the content from Running Loopback in the browser
  2. copy past the content to browser-app.js
  3. npm install loopback loopback-boot
  4. browserify browser-app.js -o app.bundle.js Then I got error: Error: Cannot find module 'loopback-boot#instructions' from '/Users/simba/Projects/traveller-app/client/node_modules/loopback-boot'
codsimba
  • 67
  • 6
  • 1
    What specifically do you need an example for? As I understand it, StrongLoop is a REST API framework for Node.JS. Do you need examples of how to get something to work in StrongLoop? Do you need examples of how to use JavaScript to interact with a RESTful API...? – Carl G Oct 27 '14 at 20:00
  • Yes, I need write a client in phonegap. I want to simply include the browser.bundle.js in my index.html, then sync data from/to server side. In fact, I'm trying to replace pouchdb/couchdb in my program since the couchdb seems not success in open source community. – codsimba Oct 27 '14 at 20:06

1 Answers1

1

There are few steps for this but its pretty simple.

  1. Bootstrap your application via slc loopback.
  2. Delete server/boot/root.js.
  3. Uncomment two lines in server/server.js, it should look like:

    ...
    // -- Mount static files here--
    // All static middleware should be registered at the end, as all requests
    // passing the static middleware are hitting the file system
    // Example:
    var path = require('path'); //this line is now uncommented
    app.use(loopback.static(path.resolve(__dirname, '../client'))); //this line is now uncommented
    ...
    
  4. Create index.html in the client dir (ie. client/index.html) with your contents.

That should get you a basic set up with just a basic front-end working. Let me know if you have any more issues.

  • Thanks, then I know how to host index.html for now. – codsimba Oct 27 '14 at 21:21
  • Still, I can't follow up this document. http://docs.strongloop.com/display/LB/Running+LoopBack+in+the+browser 1. create browser-app.js with the content from strongloop 2. copy past the content for browser-app.js 3. npm install loopback loopback-boot 4. browserify browser-app.js -o app.bundle.js Then I got error: Error: Cannot find module 'loopback-boot#instructions' from '/Users/simba/Projects/traveller-app/client/node_modules/loopback-boot' – codsimba Oct 27 '14 at 21:23
  • Take a look at this example, https://github.com/strongloop/loopback-example-full-stack/blob/c06a292ef95060f20339b18afab4467f36435997/client/lbclient/build.js –  Oct 27 '14 at 23:42