简体   繁体   English

我在需要堆栈的节点 js 中遇到错误

[英]I am getting a error in node js which is of Require Stack

Getting this error in nodejs while trying to open.js file尝试打开.js 文件时在 nodejs 中出现此错误

{ code: 'MODULE_NOT_FOUND', requireStack: } { 代码:'MODULE_NOT_FOUND',requireStack:}

Don't know what's causing this Reinstalled node js along with it's packages and removed nodejs modules and added them again but still no success Found solutions on some websites(including stackoverflow) but none of them seems to work不知道是什么原因重新安装了node js及其软件包并删除了nodejs模块并再次添加了它们但仍然没有成功在某些网站(包括stackoverflow)上找到了解决方案,但它们似乎都不起作用

This question requires more context, but here's how to think about solving the question.这个问题需要更多的上下文,但这里是如何考虑解决这个问题。 Whenever you have a 'MODULE_NOT_FOUND' error, the culprit is almost always your package.json file.每当您遇到“MODULE_NOT_FOUND”错误时,罪魁祸首几乎总是您的 package.json 文件。

Whatever code you're implementing in your .js depends on an npm module/package that is referenced in package.json, but (possibly) hasn't been installed (ie, there's no corresponding node_modules folder for the problem.无论您在.js中实现什么代码,都取决于 package.json 中引用的 npm 模块/包,但(可能)没有安装相应的node_modules文件夹

It's a bit odd that the require stack is empty, as that would have given us some insight into the problem.要求堆栈为空有点奇怪,因为这会让我们对问题有一些了解。

Consider doing as I've described:考虑按照我的描述进行:

  • Review the error and see if you can find anything in the require stack pointing to the issue.查看错误并查看是否可以在 require 堆栈中找到任何指向该问题的内容。
  • Check your package.json for all installed packages检查您的 package.json 以获取所有已安装的软件包
  • To be doubly sure, re-run npm install为了更加确定,重新运行npm install
  • Make sure your JS file is in the same directory as the package.json file确保您的 JS 文件与 package.json 文件位于同一目录中

Let me know how this goes!让我知道这是怎么回事!

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

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