Search This Blog

Archive

Check out these Pages

yangonairportonline.com

yangonairportonline.com

Contact

lynnnayko@gmail.com

upgrade nodejs mac and npm update error module js

I had a problem updating npm after installing new version of node and this solved my problem
Note: If you get "301 Moved Permanently" then try curl -0 -L http://npmjs.org/install.sh | sudo sh to follow redirects. Also notice I added sudo before the sudo sh command depending on your users permissions.

If you want to update stable version of nodejs. n is another nodejs version manager. or you can just go to nodejs.org, download and install it.

##Install module n

$ npm install -g n

$ n stable
We are going to need sudo to do this.

Resources :
https://github.com/tj/n/issues/101
http://mazharahmed.me/upgrade-node-js-version-in-mac/
https://github.com/tj/n

npm refusing to install as a dependency of itself

On
Cause : 
The name of the module you are trying to install cannot be same as the name you defined in package.json

Let's say, you are trying to install hapi module in hapi directory, rename the name to something other than hapi

{
  "name": "hapi-test",
  "version": "1.0.0",
  "description": "this is a test",
  "main": "server.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1",
    "start": "node server.js"
  },
  "keywords": [
    "test"
  ],
  "author": "wai",
  "license": "ISC",
  "dependencies": {
    "hapi": "^13.0.0"
  }
}

Here's more on package.json at https://docs.npmjs.com/files/package.json




git basic commands : working with existing project : 1

Following commands are to add remote repos to your project folder. I use bitbucket for this example.
cd /path/to/my/yourprojectgit remote add origin https://yourepo@bitbucket.org/yourrepo/myproject.gitgit push -u origin --all # pushes up the repo and its refs for the first time
And push all the folders and files under your current project folder
Add all folders and files

git add ./*

And commit
git commit -m "Your Project"

then
git push origin master

I will add more to this post.


Set up Visual Studio Code on Mac OSX

Step I : Setting up environment 


Download and Install Visual Studio Code from follow link and follow the instruction https://code.visualstudio.com/docs/editor/setup





Install ASP.NET 5 and DNX



Then append these lines to your ~/.bash_profile in your terminal

Run vim ~/.bash_profile

function code() { VSCODE_CWD="$PWD" open -n -b "com.microsoft.VSCode" --args $*; }

source dnvm.sh

export MONO_MANAGED_WATCHER=disabled

then

Run :x to save and exit vim.

Run source ~/.bash_profile or restart your terminal then run the following command.

Run dnvm upgrade

Part II : Getting Started




As shown above run following command in your terminal

npm install -g yo generator-aspnet gulp bower



Run yo aspnet

After that you will see like this. There you can choose as shown below.

After that you will see something like (for me I chose ConsoleApplication)


? ==========================================================================
We're constantly looking for ways to make yo better! 
May we anonymously report usage statistics to improve the tool over time? 
More info: https://github.com/yeoman/insight & http://yeoman.io
========================================================================== Yes

     _-----_
    |       |    .--------------------------.
    |--(o)--|    |      Welcome to the      |
   `---------´   |   marvellous ASP.NET 5   |
    ( _´U`_ )    |        generator!        |
    /___A___\    '--------------------------'
     |  ~  |     
   __'.___.'__   
 ´   `  |° ´ Y

? What type of application do you want to create? Console Application
? What's the name of your ASP.NET application? MacNET_Test
   create MacNET_Test/.gitignore
   create MacNET_Test/Program.cs
   create MacNET_Test/project.json


Your project is now created, you can use the following commands to get going
    cd "MacNET_Test"
    dnu restore
    dnu build (optional, build will also happen when it's run)

    dnx run

Then you can follow as mentioned : 

cd "MacNET_Test" //Your project folder.
dnu restore
dnx run or web //based on the application type you chose above. Build will happen when command run)

Run " code . " in your terminal to launch Visual Studio Code.


Please drop me an email or comment. Thank you!!