I recently installed a package w/ Bower from here: https://github.com/takuyaa/kuromoji.js/
Reading the installation on the github, I basically copied and pasted from the guide:
kuromoji.builder({ dicPath: "../bower_components/kuromoji/dict/" }).build(function (err, tokenizer) {
// tokenizer is ready
var path = tokenizer.tokenize("すもももももももものうち");
console.log(path);
});
However, I do not know what the "kuromoji" should refer to. Here is the obvious error:
Uncaught ReferenceError: kuromoji is not defined
Here is a screenshot of my directory tree:
Not sure how to properly use this.
import kuromoji from 'kuromoji'
That provides the 'kuromoji' object you're trying to reference
Related
I'm enthusiastic about Deno so I'm giving it a try. Found a tutorial on building a REST API here.
So, when I'm trying to run it, I get this InvalidData error:
error: Uncaught InvalidData: data did not match any variant of untagged enum ArgsEnum
at unwrapResponse ($deno$/ops/dispatch_json.ts:43:11)
at Object.sendAsync ($deno$/ops/dispatch_json.ts:98:10)
at async Object.connect ($deno$/net.ts:216:11)
at async Connection.startup (https://deno.land/x/postgres/connection.ts:138:17)
at async Client.connect (https://deno.land/x/postgres/client.ts:14:5)
at async Database.connect (file:///Users/svenhaaf/git/deno/logrocket_deno_api/db/database.js:17:5)
Now, it looks to me that something is wrong when trying to connect to the database, but I can't really figure out what.
What does this InvalidData error mean? How should I fix this?
FYI my deno --version prints:
deno 0.42.0
v8 8.2.308
typescript 3.8.3
Code:
I cloned the repo from https://github.com/diogosouza/logrocket_deno_api, and in config.js, I edited line 1 from const env = Deno.env() to const env = Deno.env, since it looks like Deno.env became an object instead of a method.
The tutorial is not using versioned URLs, and deno-postgres version that is being used is not compatible with v0.42.0, since https://deno.land/x/postgres/mod.ts is pulling from master
Change db/database.js to import from https://deno.land/x/postgres#v0.3.11/mod.ts, since v0.3.11 is the correct version for Deno v0.42.0
import { Client } from "https://deno.land/x/postgres#v0.3.11/mod.ts";
Remember to always use the version in the URL if you don't want the code to stop working when a new Deno or package version is released.
I am new to protobuf.
I have installed npm google-protobuf.
Following is my .proto file
syntax = "proto3";
package com.sixdee;
message Student{
string name = 1;
int32 id = 2;
}
And this is how i have generated the .js file
protoc --js_out=import_style=commonjs,binary:. testproto.proto
i have pasted the resulting testproto_pb.js in my project.
I am not able to build a protobuf packet.
I have tried
var student = new Student();
student.setName("Ankith");
student.setId(24);
I get Uncaught ReferenceError: Student is not defined
I have referred link. nothing seems to work for me.
Any help is deeply appreciated.
I'm not sure what is wrong with our code. It's hard to judge without the full source code.
I used protobufjs from npm as outlined here: http://webapplog.com/json-is-not-cool-anymore/
You need protobuf library on the front-end as well.
i am a newby on node.js. i want to parse a xml file into json .so i am trying to use bulebutton library from https://github.com/blue-button/bluebutton.js .
first i have installed the module by command npm install bluebutton and its created a node_modules folder with bluebutton module.
now i created a test.js file with following code
var bb = require('bluebutton');
var myRecord = bb.BlueButton('./asd.xml');
console.log(myRecord);
but its gave me an error that bluebutton is not define .please help me to figureout this problem thanks
REVISED ANSWER
From bluebuttonjs.com/docs, the require statement you use would return the BlueButton object, so bb represents said object, and it would be called like so
var myRecord = bb('someFile.xml');
However you might also note that they use fs to read the file before passing it. http://www.bluebuttonjs.com/docs/#parsing-node
PREVIOUS ANSWER (for wrong module)
According to their npm docs, you need to do
var bb = require('blue-button');
https://www.npmjs.com/package/blue-button
I am developing an Ionic app with $cordovaSQLite installed, but when I tried running openDatabase, I got the error "TypeError: Cannot read property 'openDatabase' of undefined".
I double checked my code that the openDatabase call is inside the $ionicPlatform.ready function and the database file has been properly installed, may I have any advices?
Thanks and Regards,
Jimmy
First make sure you have ngCordova properly installed. (install instructions can be found on ngcordova website), along with the named plugin.
When you get undefined error you should always look if you have the dependency defined. That is the most common mistake with people starting with AngularJS.
Example code:
//inject your dependencies;
ControllerOrConfigFunction.$inject = ["$scope", "$cordovaSQLite"]
function ControllerOrConfigFunction($scope,$cordovaSQLite){
//your code here
}
This applies to all functions in which you are using the $cordovaSQLite plugin.
You can also find a great example on ngCordova website.
There are multiple ways you can define your Dependency Injection in AngularJs, i recommend it for now, after that take a look at ng-annotate.
if (window.cordova) {
db = $cordovaSQLite.openDB({ name: "my.db" }); //Device
console.log("Android");
}
else
{
db = window.openDatabase("my.db", '1', 'my', 1024 * 1024 * 100); // Browser
console.log("browser");
}
Can anyone give me any pointers/examples on how to use your own custom helpers with grunt-static-handlebars? I've read the documentation and can't see how to do this.
I created helpers to use when using handlebars client side and I'd love to be able to replicate that on the serverside when building pages but currently can't work out how to do that.
I tried to create the fullName helper from the handlebars docs. I set my helpersPath to /helpers and created a fullName.js with this code
Handlebars.registerHelper('fullName', function(person) {
return person.firstName + " " + person.lastName;
});
Then I added it to the base.json config file
{
...
"helpers": [
"fullName"
],
...
}
And then attempt to use it in a partial {{fullName person}}
But when I attempt to run the grunt task I getting an error. Fatal error: Object #<Object> has no method 'call'
Any ideas where I'm going wrong?
You can try out grunt-handlebars-to-static, which have a example project available solving your exact problem. Also the task is highly flexible for all different kinds of folder arrangement. The docs gives two examples of most typical folder arrangement as starters.
Disclaimer: I am the author :) Cheers.