简体   繁体   English

找不到模块./dist/es5 node.js

[英]cannot find module ./dist/es5 node.js

I am just getting started with nodejs. 我刚刚开始使用nodejs。 Currently I am stuck in a problem where I am trying to install " exceljs " library in my system. 当前,我陷入了一个问题,试图在系统中安装“ exceljs ”库。 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. 我正在使用公司的便携式计算机,但是我尝试在系统上安装“ npm install exceljs”是徒劳的,因为该便携式计算机位于代理墙后面,并且无法正常安装。

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. 我仍在从IT支持人员那里获取代理详细信息的过程中,但是需要一些时间,与此同时,我尝试从Github安装该库的本地副本,但遇到了一些问题。

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: 当我尝试使用node helloexcel.js从cmd运行它时,抛出以下错误:

在此处输入图片说明

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. 我仍然绕着这个错误./dist5/es5运行,不知道这是什么,因为我什至在我从github下载的exceljs库文件夹中都找不到它。

What I tried: 我试过的

1). 1)。 I tried all the ways to npm install packages in my system, but still no luck due to proxy problems 我尝试了所有方法来在系统中npm安装软件包,但是由于代理问题仍然不走运

2). 2)。 for ./dist5/es5 i tried reading here but I am not able to follow whats written there 对于./dist5/es5我尝试在这里阅读但我无法跟随那里写的内容

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. 编辑:我最近解决了我的问题,这一切都在发生,因为由于代理问题而无法执行“ npm install exceljs”。 I followed a link to the post where it was mentioned to install Fiddler and after some easy configurations in .npmrc file it worked. 我点击了指向该帖子的链接,该帖子提到要安装Fiddler,并在.npmrc文件中进行一些简单的配置后,它可以工作。 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. 请参考下面我的评论。

You can config your proxy host with npm, you can search about this out there, many answers. 您可以使用npm配置代理主机,可以在那里搜索有关此内容的许多答案。

Ex: Is there a way to make npm install (the command) to work behind proxy? 例如: 有没有办法使npm install(命令)在代理后面工作?

After that, run npm install exceljs to push exceljs into node_mudles folder of your project. 之后,运行npm install exceljs将exceljs推送到项目的node_mudles文件夹中。

Then in your js file, just doing 然后在您的js文件中,

var Excel = require('exceljs');

It just runs. 它只是运行。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM