Permission Denied Error On Npm Install For Yeoman

Yeoman 007

I was trying to create a simple ASP.Net 5 project by using generator like Yeoman on my Mac. The instructions on ASP.Net docs website are simple and easy to follow. However I encountered a permission denied error on npm install for Yeoman.

Npm Error Permission Denied

Initially I thought I was not running an updated npm version so I tried to execute npm upgrade, but it did not work. I also tried to install again npm getting the installing from nodejs.org but the same error occurs.

Looking closely at the log, it was a permission error on a mkdir on /usr/local/bin folder. This was verified when I go to that folder and tried to create a folder but a permission error occurs. Getting closer to the root of the problem!

Wheels

When I looked into the owner and group permissions in the folder, the group owner for node_modules (where the install is targeting the mkdir) is a group name wheel. The group name wheel seems to have been related to the roots of MAC OS X from Unix.

Wheels MacOS Permission

I issued two commands to gain permission to the folder.

sudo chgrp -R admin node_modules

sudo chown -R whoami nodel_modules

After gaining permission to the folder, I once again tried to install Yeoman using npm and the installation went through this time.

Npm yo Ok now

I hope this will save you time if ever you encounter the same problem on your way to trying more ASP.Net 5 samples.

Taking Visual Studio Code and ASP.Net 5 For A Spin

Visual Studio Code Setup

Visual Studio Code Download

https://code.visualstudio.com/Download

Visual Studio Code (VSCode) is the latest free cross platform lightweight IDE from Microsoft. Visual Studio Code and ASP.Net 5 are being released as free and open source.

Initial Impressions for Visual Studio Code

Pros:

  • Lightweight IDE
  • Support for many Languages with IntelliSense
  • Git Integration
  • Open Folder
  • Easy Split Window Navigation
  • User and Workspace settings in JSON

Cons:

  • Does not support regions for C#
  • Keeps hanging when you use on large .Net solutions (Open Folder)

ASP.Net 5 Setup

According to Microsoft, DNX was built entirely from the ground up. The ASP.Net 5 was also created from the ground up, meaning all ASP.Net 5 projects are DNX projects. Good thing to note is that ASP.Net 5 is not anymore based from System.Web.dll. Things are built around the concept of packages and on demand references.

Windows

In order to install and run ASP.Net 5 from Windows, you will need to install the DNVM (Version Manager), DNU (Utility) and DNX (Execution Engine). The steps to install them can be found from this link.

OSX

A very cool new feature of ASP.Net 5 is that it can run and be developed in other platforms. I was very excited to try and develop ASP.Net on a non-Windows machine. It gave me enough reason to buy and upgrade my MacBook Pro 2008 to MacBook Pro 2015 ;).

Just like in Windows, you will need to install the DNX, DNVM and DNU. But this time, since its on OSX, everything will be dependent on Mono (.Net Open Source Project). You can get Mono by installing through Homebrew (package manager) in OSX. Actually, it works backwards, in Homebrew when you install the latest ASP.Net and DNX it installs Mono automatically since its a required package of ASP.Net.

Linux soon!

I do not have now a Linux machine to try and install ASP.Net 5 so next time I will post my ASP.Net 5 adventures with Linux!

Sample Project ASP.NET 5

Omnisharp log – Error logged on opening the sample project

When opening the sample ASP.Net 5 DNX project with VS Code without first installing DNX, you will encounter an error logged under the Omnisharp log. This is a good way to know the sequence where it looks for the DNX framework.

Omnisharp log

The DNX framework can be installed on your system like what I did when I followed the steps to initially setup DNVM, DNU, DNX amongst others. But you can also, make available the different DNX versions in your local by getting and compiling them from the Github repository. This way, you can test different versions of DNX from your system. Running DNVM list will show you different versions installed in your machine.

Two versions of DNX

Running the sample apps

There are sample projects up in the ASP.NET repository. You can download or clone them from Github.

I tried to open and run the web application under the HelloMVC sample folder. This is a sample MVC ASP.NET 5 project which you can open in VSCODE.

Inside the project folder, you can execute

dnu restore

to make download the dependencies of the sample project. Visual Studio Code will also prompt you to do the restore.

DNU Restore VSCode Window

DNU Restore Complete

To execute and start the hosting of the project run the command

 dnx . web 

DNX WEB

Open a browser and go to http://localhost:5001/ and you will see the sample MVC ASP.NET 5 project running.

Sample ASP NET 5 Website running

You can do the same steps to setup, compile and run the web project in OSX. As long as you have DNX installed you can start and run ASP.NET 5 projects. I’m trying to follow the latest in DNX and ASP.NET as a whole in Github – http://www.github.com/aspnet and try to contribute if possible 🙂 Thanks and until my next post!

Ajax Not Passing Parameters Using Internet Explorer – Solved

I was trying a simple ASP.Net project that calls a web service using AJAX. I just want to try some stuffs I can do with AJAX and JQuery in my desktop. Sort of just diving into the code and expecting that as simple as this would work in 5 minutes. But no, I guess its that kind of a problem that will only happen in your machine and not with others. Thanks to the Download Accelerator Plus installed on my machine I would have not encountered Ajax not passing parameters to the web service. Arrgh!.

Ajax Not Passing Parameters

As you would expect, I got the following components in my ASP.Net project to work on the  simple Ajax call test that I want to do.

Web Service

[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string CheckIfGalaxyGuardian(string guardian)
{
var guardians = new[] { "Peter", "Gamora", "Drax", "Groot", "Rocket" };

if (guardians.Any(x => x == guardian))
return "We are Groot!";
else
throw new Exception(string.Format("{0} is not a Guardian.", guardian));

}

 

 Asp.Net Page

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>JSON Exception Sample</title>
<script src="Scripts/jquery-1.8.2.min.js"></script>
<script src="Scripts/Guardian.js"></script>
<meta http-equiv="x-ua-compatible" content="IE=9" />
</head>
<body>
<form id="form1" runat="server">
<div>
<input type="button" id="btnSubmit" value="Check Galaxy Guardian"/>
<input type="text" id="name"/>
</div>
</form>
</body>
</html>

 

Javascript

$(document).ready(function () {

$("input[type=button]").click(function () {

var guardian = $("input[type=text]").val();

// Ajax call to service.asmx.
$.ajax({
type: 'POST',
url: 'GuardianSvc.asmx/CheckIfGalaxyGuardian',
data: JSON.stringify({ guardian: guardian }),
contentType: "application/json",
dataType: 'json',
success: function (result) {
alert(result.d);
},
error: function (result) {
var e = JSON.parse(result.responseText);
alert(e.Message);
}
});

});

});

 Invalid web service call, missing value for parameter error

When I ran the application I got the error : Invalid web service call, missing value for parameter… Ajax is not passing the parameters to the web service. When you look at the message in fiddler it will show you that no data was passed into the request.

Fiddler Request Message  Before DAP

Fiddler Response Message  Before DAP

When I tried to use Chrome, it works. So what is wrong with using Internet Explorer?

I tried using the Chrome browser and voila everything is working as expected. I did not do any change in my code. It just works with Chrome.  I tried searching about the issue and I got into this Stackoverflow post about IE refusing to send POST data. One of the comments recommended that uninstalling FDM (Free Download Accelerator) fixed the issue for him. I remember having a download manager on my machine so I tried to look  a download manager installed and saw that Download Accelerator Plus is installed. My hope is restored.

Disable Download Accelerator Plus or Free Download Manager

Download Accelerator Plus  Disable IE Integration

Try again with IE

After disabling DAP on my Internet Explorer, I tried running the same web project and now it works.

Fiddler Response  Ajax working in IE

Not A Guardian

Galaxy Guardian

If you can search Google and hopefully see this post the first time you encountered the same problem, congratulations! I might have saved you couple of hours debugging your program 🙂