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

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.

Related

How do I solve the problem of modules not found in angular application?

I have an angular application that uses two libraries locally, however, when trying to build everything ending up with an error of modules not found, but I thought it was some problems of undeclared dependencies, or imported, but everything is fine.
For better understanding, I have: Two local libraries that are used by a test application, where this application consumes both libs, but in the compilation it presents the error of modules not found:
`Error: Module not found: Error: Can't resolve '#ngx-formly/example-kendo' in 'C:\SamuelPierre\Example\Repositório\NgBibliotecas\NgBibliotecas\projects\framework-example\src\app\shared'
Error: projects/framework-example/src/app/app.component.ts:1:34 - error TS2307: Cannot find module '#example-library/identity' or its corresponding type declarations.
1 import { UserTokenService } from '#example-library/identity';
~~~~~~~~~~~~~~~~~~~~~~~`
This error appears for all dependencies, but my main file has all the necessary imports and declarations.
Also, "npm install" to install the libraries doesn't help as they are accessed locally. I've already cleaned the node modules, reinstalled npm, everything is ok, but the problem persists.
maybe you should run npm install or when it just one module just do npm install <module name> -save
Try (in Terminal):
npm install

Node application not running on remote server, runned on PC

I have a program developed in javascript that runs in node, it works perfectly on my windows and ubuntu environment but for some reason, it does not work on a remote new server I installed it.
I did the same things I did with my personal environment, install node, install MongoDB, install the packages and run it. but for some reason, it shows an error it didn't show before
Error:
DONE Compiled successfully in 547ms
/home/servinfo/DynamicButtons/build/webpack:/src/routes.js:18
module.exports = app => {
^
TypeError: Cannot assign to read only property 'exports' of object '#<Object>'
at Object.<anonymous> (/home/servinfo/DynamicButtons/build/webpack:/src/routes.js:18:1)
I execute it using backpack-core, I run "npm run dev" and showed me this error(actually bigger but this is what matters)
Usually what I do in these cases:
check node version
check package.json to have all the dependencies including devDependencies for package managers and other building services
remove node_modules/
remove package_lock.json
npm install again
That usually helps

How to get Twig.js for the browser

I'm using Twig as my templating system on server side and also want to use it client side (to use the same templates).
I'm also using Bower and tried this command to get Twig.js:
bower install twig.js
But that didn't install all folders as seen here https://github.com/twigjs/twig.js. Then I tried to install other recent branches and commits but still 2 folders were missing at least (bin & src).
After that, I tried cloning the project using Git and it worked because it really got all listed files and folders.
But then when I include twig.js in my HTML file throws this error in the Chrome console log:
twig.js:13 Uncaught ReferenceError: require is not defined
My best guess is that function "require" belongs to Node.js (right?) and there must be some kind of compilation to get Twig.js for the browser (right???).
So, I don't know what is next... How can I get the Twig.js for the browser? (Meanwhile I'm going to get Twig.js from a CDN).
Please help me.
I don't know which version of Twig.js you were using, since the question was posted almost 2 years ago, but probably something 0.9.x or higher. Since that version the maintainers did not commit any JS files compiled for web usage in the root of the project.
So yes, the JS files inside the src/ folder are NodeJS files and you have 'to do something' before you can use them in your browser. The library is using Webpack to build a browser compatible version.
You should run npm install in the root of the GitHub clone to set up the project and then run npm run build in order to build a web version. Check for twig.js in the root after that.
Using a CDN version is also a good option. But because the builds were left out since version 0.9.0 there is no newer version of Twig.js on cdnjs than 0.8.9 while the library is currently on version 1.12.0
Or run npm install twig --save, the compiled files are at:
node_modules/twig/twig.js and
node_modules/twig/twig.min.js
You have to install RequireJS to use require("twig");. Install that first and then run.

Getting node modules working in browser

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

Error: Cannot find module 'entities/lib/decode_codepoint.js'

I am using cheerio module for web scraping . It require htmlparser2 module , after installing htmlparser2. it gives following error-
Error: Cannot find module 'entities/lib/decode_codepoint.js'
Use this in your terminal:
npm install grunt-contrib-jshint --save-dev
Seen here:
https://www.npmjs.com/package/grunt-contrib-jshint
Below is applicable to Windows environment only, not Linux.
I received the same error when I tried to build jquery from source on Windows. It turns out that jsdom and/or grunt-contrib-jshint (both of which depend on htmlparser2) require gyp and for gyp to work you need a c++ compiler and python. I thought that I had them but turned out, that python need to be version 2.x not version 3.x. If it is 3.x it gives you a proper error on the first run (that I missed) and on subsequent runs you are getting the error in the question above which makes you wonder what's going on.
So I uninstalled python 3.x, installed python 2.x (don't forget make sure that python.exe is in your path), then deleted the node_modules folder in the project root and ran the build again.
This time around it worked. I'm not sure if this solves the OP question, but I hope it helps someone.

Categories

Resources