0

I am just getting started with nodejs. Currently I am stuck in a problem where I am trying to install "exceljs" library in my system. I am working on corporate laptop and I tried in vain installing "npm install exceljs" on my system, because this laptop is behind proxy wall and its failing miserably to allow me to install anything.

I am still under process of achieving proxy details from IT support but it will take some time, meanwhile, i tried installing a local copy of this library from Github but ran in several problems.

Here is code that i am trying to run:

var Excel = require("C:/Users/itsme/project_folder_imp/src/exceljs-master/excel.js");
var workbook = new Excel.Workbook();
workbook.xlsx.readFile('file.xlsx')
.then(function() {
    var worksheet = workbook.getWorksheet('sheet');
    var i=1;
    worksheet.eachRow({ includeEmpty: false }, function(row, rowNumber) {
      r=worksheet.getRow(i).values;
      r1=r[2];
      console.log(r1);
      i++;
    }); 
    worksheet.getCell('B3').value = "abc";
return workbook.xlsx.writeFile('file.xlsx')  
   }); 

When i try to run it from cmd using node helloexcel.js it throws below error:

enter image description here

I am still running around circles of this error ./dist5/es5 and have no idea whatsoever what is this as I cannot even find it in exceljs library folder which i downloaded from github.

What I tried:

1). I tried all the ways to npm install packages in my system, but still no luck due to proxy problems

2). for ./dist5/es5 i tried reading here but I am not able to follow whats written there

It will be really helpful to get this error resolved as i simply cannot proceed and have already wasted lots of time behind this.

EDIT: I have solved my problem recently and it was all happening because I was not able to do "npm install exceljs" due to proxy problem. I followed a link to the post where it was mentioned to install Fiddler and after some easy configurations in .npmrc file it worked. I have also included a link to that same post which finally helped me to resolve proxy block in the company. please refer to my comment below.

Radheya
  • 779
  • 1
  • 11
  • 41
  • I'm not familiar with the exceljs package, but it seems the code at github needs to be built before being usable as npm package. Have you tried running "npm run build" inside the exceljs path before using it? – lleon Aug 01 '17 at 15:43
  • I did not tried previously, but when i tried it now I am still getting that shitty "check if you are behind proxy" problem. i am working on my company's laptop. Is there any other way to build github code which i downloaded? – Radheya Aug 01 '17 at 15:53

1 Answers1

1

You can config your proxy host with npm, you can search about this out there, many answers.

Ex: Is there a way to make npm install (the command) to work behind proxy?

After that, run npm install exceljs to push exceljs into node_mudles folder of your project.

Then in your js file, just doing

var Excel = require('exceljs');

It just runs.

thelonglqd
  • 1,805
  • 16
  • 28
  • i am trying to configure my proxy host using npm, but i must wait for my IT department to provide me correct proxy details. i will try your method once i set the proxy so that npm install runs without problem. – Radheya Aug 02 '17 at 07:59
  • You can copy entire exceljs folder lib to node_modules in your project and then require as I mentioned above. – thelonglqd Aug 02 '17 at 08:11
  • I did as you said, copied exceljs folder to node_modules located in nodejs folder. still not working. shows same error as described in question. i think npm install is the only way left now. these shitty laptops have lots of restrictions on it. – Radheya Aug 02 '17 at 08:31
  • I was finally able to solve my proxy related problem by installing Fiddler as advised in this answer [here](https://stackoverflow.com/questions/18569054/npm-behind-ntlm-proxy/36929905#36929905) and following the steps given in @thelonglqd's answer – Radheya Aug 03 '17 at 08:28