How to fix "cannot find module {the path to my folder}" when using javascript code (im running it using node .)

huangapple go评论64阅读模式
英文:

How to fix "cannot find module {the path to my folder}" when using javascript code (im running it using node .)

问题

我正在编写 JavaScript 代码(只是简单的 web 服务器,因为我是个初学者开发者),然后我遇到了上面的错误(参考标题),我尝试了我记得的每一种老办法(因为我在过去曾经面对过这个错误),但有用吗?不。现在我已经在 Stack Overflow 上提问了,所以嗯,求助

我尝试过的方法:

我尝试重新打开文件之类的事情(这在过去曾经解决过我的问题),说实话,我甚至不知道这是否足够详细。

英文:

I was writing JavaScript code (just plain 'ol web servers because I am a noobie dev) and I got the above error (Refer to title) and I tried every old way I remembered (as I faced the error in the past) but did it work? Nein. And it came to the point where I am now asking this on Stack Overflow, so uh yeah help

What I tried:

I tried like re-opening the file and stuff similar (It resolved the issue for me in the past), I don't even know if this is detailed enough tbh

答案1

得分: 0

请按照以下步骤操作:

  • 运行 rm -rf node_modules 删除 node modules 文件夹
  • 运行 rm -f package-lock.json 删除 package.lock.json 文件
  • 运行 npm cache clean --force 清理 NPM 缓存
  • 运行 npm install 重新安装所有包
英文:

Please follow following Steps:

  • Delete the node modules folder by running rm -rf node_modules
  • Delete package.lock.json file by running rm -f package-lock.json
  • Clean up the NPM cache by running npm cache clean --force
  • Install all packages again by running npm install

huangapple
  • 本文由 发表于 2023年3月31日 19:44:24
  • 转载请务必保留本文链接:https://go.coder-hub.com/75898157.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定