Getting node modules working in browser - javascript

I need to make one node module run in browser. The node module is fury.js. I tried browserify but when trying to use it it gives error "ReferenceError: fury is not defined". In browserify js/main.js, I only did a 'require' var fury = require('fury');. An output file was also generated by browserify but I'm not able to use it in my browser, because of the error mentioned above. I am very novice in nodejs & browserify world, need some help.

You need to install the package locally using npm in order to be able to use it via browserify:
npm install --save fury

Related

nodeJS: Command not found when installed a library from source code instead of npm library

I am trying to install nodeJS library by downloading the source code instead of npm library, because I want to use some new features that are not present in the official library yet but I am getting command not found error.
I am trying install this package https://www.npmjs.com/package/bids-validator
I was able to use npm install -g bids-validator and it is installing the package and I am able to use it.
But If download source code from GitHub https://github.com/bids-standard/bids-validator and go to the the folder and use npm install, I didn't get any installation errors but I am getting following error
'bids-validator' is not recognized as an internal or external command,
operable program or batch file.
How do I fix this?

Getting Node Module Error (Cannot find module)

I am learning the Automated tests by using selenium web driver + Javascript and node.js.
Everything is working fine when I ran that script.js from the Visual Studio code terminal(by using node main.js)
Problem
I want to schedule this script in the scheduler which automatically tests the login functionality. But when I try to run it from the task scheduler then it gives Error: Cannot find module
Does anybody know how to get rid of this.
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's app. ... or delete the node_modules folder and package-lock. json file and re-install it again using the npm install command.
rm -rf node_modules package-lock.json

How does this javascript import of kurento-utils get recognized?

On this line:
https://github.com/Kurento/kurento-tutorial-java/blob/master/kurento-player/src/main/resources/static/index.html#L24
This javascript file is imported. However, there is no file called "kurento-utils.js" in this package. So how does this work? Is this some magic of bower?
Where does that file come from and how can I get it to be accessible in my code?
When I run this code, I get:
(index):281 Uncaught ReferenceError: kurentoUtils is not defined
Thank you!
Where is no magic:
git clone https://github.com/Kurento/kurento-utils-js
cd kurento-utils-js-master
npm install
To build the browser version of the library you'll only need to exec the grunt task runner and they will be generated on the dist folder. Alternatively, if you don't have it globally installed, you can run a local copy by executing:
node_modules/.bin/grunt
(for windows i run grunt.cmd)
cd kurento-utils-js-master/dist
Here we are
copy kurento-utils.js in your resource folder

ELM327 Bluetooth OBD-II adapter using Eric Smekens node-bluetooth-obd

Iam getting the following error ReferenceError: require is not defined in browser when i try to run Eric Smekens node-bluetooth-obd test.js
when adding require.js the following error has been seen "error: Module name "../lib/obd.js" has not been loaded yet for context: _. Use require([])
http://requirejs.org/docs/errors.html#notloaded"
I have tested this on firefox and IE edge any suggestions regarding these errors please.
i am just running them to understand the code though it wont gets execute here.
The module should be used in Node.js environment, not in browser environment.
Install Node.js, then in command-line create a package.json file with npm init, install the module npm install --save bluetooth-obd and then use it in your script like this require('bluetooth-obd'). To run the script, type node myscript.js.

Trouble installing a module as a global variable -- /usr/bin/env not a directory

I am attempting to install the node.js module 'javascripting' (source code can be found: https://github.com/sethvincent/javascripting) and have been unable to install it as a global variable to run through the terminal.
After installing node.js I attempted to install javascripting with the line: npm install --global javascripting
While it is my understand that this should work, it only downloads the module but does not set it as a global variable to be run in terminal.
The error I receive when attempting to run it as a global variable is "/usr/bin/env: node: No such file or directory".
After receiving this error I attempted to move the module to /usr/bin/env from the directory it installed in (usr/local/lib/node_modules/javascripting). Unfortunately, I was not able to move the files because /usr/bin/env is not a directory, rather it seems to be some sort of executable java file (usr/bin is a directory).
I am a bit lost and would love some advice on either how to install the module as a working global variable or whether there is another way to run the module without installing it as a global variable.
This will happen if the node.js binary (node) is not installed in the $PATH anywhere.
if you run env node by itself, you will get the same error. It looks like this may be an Ubuntu bug: https://github.com/joyent/node/issues/3911
Try sudo ln -s /usr/bin/nodejs /usr/bin/node - that will symlink the node.js binary from the name Ubuntu gave it to the name it's supposed to have.
EDIT:
As mscdex pointed out in a comment (and as mentioned at the end of the bug I linked), there's a legacy package you can install that should create this symlink.
sudo apt-get install nodejs-legacy
The bug I linked above indicates that there are probably other problems with Ubuntu / Debian's default node.js package, and recommends you install your own either from the PPA mentioned there or from source.
You'll probably need to follow the advice in NPM modules won't install globally without sudo as well.

Categories

Resources