Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I start this Node.JS application?

There is an open-source application which visually displays a difference between two BPMN diagrams.

I want to see what the application looks like when it runs.

How can I start it under Ubuntu?

I tried to run node app.js in the directory bpmn-js-diffing/app but got the error

module.js:341
    throw err;
    ^

Error: Cannot find module 'jquery'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at bpmn-js-diffing/app/app.js:6:11
    at Object.<anonymous> (bpmn-js-diffing/app/app.js:435:3)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)

I looked at the Gruntfile in search of a "run" command, but only found these

grunt.registerTask('test', [ 'karma:single' ]);

grunt.registerTask('auto-test', [ 'karma:unit' ]);

grunt.registerTask('default', [ 'jshint', 'test', 'browserify:standaloneViewer', 'jsdoc' ]);

To me they look like commands for running automated tests and generating documentation, not for running the actual application.

So how can I start this application?

Update 1: Ran npm install in bpmn-js-diffing directory. Then tried to run node app.js again (in the bpmn-js-diffing/app) directory. Here is the result:

bpmn-js-diffing/app$ node app.js 
module.js:341
    throw err;
    ^

Error: Cannot find module 'bpmn-js-diffing'
    at Function.Module._resolveFilename (module.js:339:15)
    at Function.Module._load (module.js:290:25)
    at Module.require (module.js:367:17)
    at require (internal/module.js:16:19)
    at bpmn-js-diffing/app/app.js:9:17
    at Object.<anonymous> (bpmn-js-diffing/app/app.js:435:3)
    at Module._compile (module.js:413:34)
    at Object.Module._extensions..js (module.js:422:10)
    at Module.load (module.js:357:32)
    at Function.Module._load (module.js:314:12)

like image 906
Dmitrii Pisarenko Avatar asked Aug 03 '19 12:08

Dmitrii Pisarenko


People also ask

How do I run a node JS command?

Node. js can run shell commands by using the standard child_process module. If we use the exec() function, our command will run and its output will be available to us in a callback. If we use the spawn() module, its output will be available via event listeners.


4 Answers

One big part of the Node.Js ecosystem is npm which comes with NodeJS. This is how dependencies are managed. Many NodeJS programs will have a package.json file which describes various things about them, like for example what are their dependencies. By running npm install NPM will look at what packages the program needs, and install them automatically.

like image 186
Ivan Rubinson Avatar answered Oct 08 '22 11:10

Ivan Rubinson


You need to install jquery module. 'npm i jquery'.

like image 29
mukesh kumar Avatar answered Oct 08 '22 13:10

mukesh kumar


Here is a procedure to run this application

I finally found that you didn't even need to execute npm install command to run this project. Indeed, the app/bpmn-viewer.js file embed all the necessary modules inside its source mapping.

To display the code, either open the Sources tab in Chromium Developer tools or open the 3.2 MB file. The last line begins with // # sourceMappingURL =. Copy and paste each character from data: application / json; base64,at the end of the line (XX0 =) in the address bar of a browser.

Installation

$ git clone https://github.com/bpmn-io/bpmn-js-diffing
$ cd bpmn-js-diffing

Startup local HTTP server on port 7357
Don't change dir, you must run this command in project root

python -m SimpleHTTPServer 7357

Run

Open http://127.0.0.1:7357/app/ in a browser

Demo (running on Ubuntu 18.04)

bpmn-js-diffing demo

You can compare other files by loading them from resources/ directory.

You can use any local HTTP server instead of the embedded python one, for example live-server.
Do do this, run the following commands at project root :

npm install live-server
./node_modules/.bin/live-server

Then browse to http://127.0.0.1:8080/app (default port 8080 can be changed, run live-server --help for more information)

like image 36
Stephane Janicaud Avatar answered Oct 08 '22 11:10

Stephane Janicaud


In node js whenever you use require('module_name') it will search the node_module folder in your project directory or it can go to the global node_module folder. If the required module is not there, it will give Cannot find module module_name, you can do npm i module_name to resolve. also, you can save all the required dependencies in package.json folder by using npm i module_name --save command so that if you need to run the same code on the different environment you do not install each module separately you just need to do npm i and if will refer package.json folder and install a the dependencies.

like image 24
mehta-rohan Avatar answered Oct 08 '22 11:10

mehta-rohan