Showing posts with label Node.js. Show all posts
Showing posts with label Node.js. Show all posts

Thursday, November 3, 2022

Running Only One Test.js File in Mocha

 

So in this project I have myexec.test.js inside of test directory as shown below

And then I would like to run only myexec.test.js, so in my package.json, I put this

so in line 15. "myexec": "mocha ./test/myexec.test.js". It means when I run

npm run myexec 

Then it will gonna run only myexec.test.js file....

Here is the result:


niceee.... Hope this usefull hahaha... *kidding...

Wednesday, September 29, 2021

Port Already in Use (Node.js, or other js js)

 


Solution :





Thursday, February 1, 2018

EPERM : Operation Not Permitted - Nodejs

I got 'EPERM: Operation not permitted' when installing 'npm -g vue-cli' as shown below :

The solution is just executing 'npm cache clean --force' :

Result :

Awesome.... Error has been fixed...

Sunday, January 21, 2018

Creating New Quasar Project using Windows 7

run
npm i -g quasar-cli --no-optional


After successfully installing quasar, we can execute this command :

Above steps are only executed once, so when we wanto create another quasar project in future, we don't have to do those commands again. We can simply just create our first quasar app yeaaah.... :D
Ok let's create our first quasar app by running this command :
Now we can see the project structure of quasar app like this :
Next let's jump to our quasar project app, 'cd quasar_first' and then execute 'npm install' for installing quasar dependency ....
Last... Just run quasar by executing 'quasar dev'



Wednesday, December 13, 2017

How to check object property in Node.js

Here's the way...


 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
var my_obj = {
    name : "Hisoka",
    skills: "Bungejigum"
};

if(my_obj.hasOwnProperty('status')) {
    console.log(" my object has status property");
} else {
    console.log(" status is NOT in there");
}

if(my_obj.hasOwnProperty('skills')) {
    console.log(" my object has skills property");
} else {
    console.log(" skills is NOT in there");
}

/**
* Another way for checking property is using 'in'.
* but BE CAREFUL! The in operator matches all object keys,
* including those in the object's prototype chain.
* So it's preferred to use hasOwnProperty
*/
console.log("\n");
if('status' in my_obj) {
    console.log(" status is in there");
} else {
    console.log(" status is NOT in there");
}


if('skills' in my_obj) {
    console.log(" skills is in there");
} else {
    console.log(" skills is NOT in there");
}

Result :

Saturday, December 9, 2017

Slack USERS.LIST api test using nodejs

Official documentation :
https://api.slack.com/methods/users.list

Here's mine using node js


Full source code :
https://github.com/HyosokaPoipo/slack_api_test/blob/master/poipo_request.js.
Look at function named poipo_request_slack_users_list

Slack API.TEST using Node.js

Official documentation :
https://api.slack.com/methods/api.test

My request :
 Response:

Second Way :


Full source code can be found in my github here :
https://github.com/HyosokaPoipo/slack_api_test

Search for poipo_request.js

Tuesday, April 25, 2017

Dasa Jade Template - NodeJS

Di postingan sebelumnya kita udah ngekonfig node express yg basic... Naah disini kita nyoba2 jade template yg basic2... :)
Contoh jade templatenya bisa dilihat di layout.jade didalam folder views kyk gambar di bawah :
Terus 'block content' itu bisa dilihat didalam index.jade kyk gini :
Tampilannya seperti ini :




Friday, April 21, 2017

SailsJS untuk Pemula - part I

Pertama-tama mari kita install SailsJS-nya pake npm ajjah. Silahkan jalankan perintah ini :

'npm i sails -g --no-optional'
Naah... disitu -g flag buat global directory, trus --no-optional biar g' usah nginstall dependencies di windows (soalnya skrg lg make windows 7)
Silahkan ditunggu beberapa menit biar packagenya kedownload ke repo local kita. Tar klu udah selese, kita bisa nyoba pake command 'sails -h' yg hasilnya kek gini :
Naaah... berikutnya kita ngebuat project sails baru pake perintah ini 'sails new myFirstSails'
myFirstSails itu nama folder project kita tar klu udah jadi.......
Struktur folder utama project sailsnya kyk gini :
Terus folder model dan controllernya ada didalam folder api kyk gini :
Naah...terakhir klu projectnya mau di run, pake perintah 'sails lift'

Port defaultnya 1337... Kalu dibuka tampilannya seperti ini :

Cooool...... Cukup sekian dl untuk part pertama... :D

Wednesday, April 19, 2017

Nodejs Express Generator

Next, let's install express-generator by running this command "npm i express-generator -g --no-optional" 

I'm ruunning nodejs in windows 7, so I need that --no-optional flag in order to prevent fsevent error message :D

After installing express-generator, we can see it's folder inside node-modules like this 
Next.... Let's test our express generator by running 'express -h' like this :

Ok... Let's create our first express-generator project 'express myFirstExpGen'
After running that command, we can see our directory content like this :
Btw,, actually we can specify view engine by using --v=pug|jade|ejs and etc. We also can specify css engine by using --c=less|stylus|sass|compass.... In this post I'm using default engine so it will be jade for view and plain css for css.

Next, let's run 'npm install' for installing project dependencies..

Last... Let's run our express, for windows, we can use this command :
'set DEBUG=projectDirName:* & npm start'

And then open localhost:3000 
Yeeei.... btw.... www file inside of  bin directory is our starting project file, and that file loads app.js.

Aaaand in this default project, we already have /users so if we open the page we will gonna see something like this :
It's content :