Search code examples
javascripthtmlnode.jsofflinestrongloop

I need a strongloop example wrote in javascript without angular


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'

Solution

  • 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.