[英]internal/modules/cjs/loader.js:968 throw err; ^ Error: Cannot find module '../../temp'
My Node.js app is throwing the error below:_我的Node.js应用程序抛出以下错误:_
C:\Users\vinod\server>npm start
> server@1.0.0 start C:\Users\vinod\server
> nodemon expGqlServer.js
[nodemon] 2.0.4
[nodemon] to restart at any time, enter `rs`
[nodemon] watching path(s): *.*
[nodemon] watching extensions: js,mjs,json
[nodemon] starting `node expGqlServer.js`
internal/modules/cjs/loader.js:968
throw err;
^
Error: Cannot find module '../../temp'
Require stack:
- C:\Users\vinod\server\resolvers\post.js
- C:\Users\vinod\server\node_modules\@graphql-toolkit\file-loading\index.cjs.js
- C:\Users\vinod\server\node_modules\merge-graphql-schemas\index.cjs.js
- C:\Users\vinod\server\expGqlServer.js
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:965:15)
at Function.Module._load (internal/modules/cjs/loader.js:841:27)
at Module.require (internal/modules/cjs/loader.js:1025:19)
at require (internal/modules/cjs/helpers.js:72:18)
at Object.<anonymous> (C:\Users\vinod\server\resolvers\post.js:2:14)
code: 'MODULE_NOT_FOUND',
requireStack: [
'C:\\Users\\vinod\\server\\resolvers\\post.js',
'C:\\Users\\vinod\\server\\node_modules\\@graphql-toolkit\\file-loading\\index.cjs.js',
'C:\\Users\\vinod\\server\\node_modules\\merge-graphql-schemas\\index.cjs.js',
'C:\\Users\\vinod\\server\\expGqlServer.js'
]
}
[nodemon] app crashed - waiting for file changes before starting...
I tried deleting and re-installing the node_modules
directory and package-lock.json
file, but with no result.我尝试删除并重新安装
node_modules
目录和package-lock.json
文件,但没有结果。
I got a similar problem.我遇到了类似的问题。 Try this:
尝试这个:
npm install request
This solved the problem for me.这为我解决了这个问题。
Turns out, my program was referring to a temp folder in the current directory, but the path was incorrect.原来,我的程序指的是当前目录中的临时文件夹,但路径不正确。 ie const{posts}=require('../../temp');
即const{posts}=require('../../temp'); I changed it to const{posts}=require('../temp');
我将其更改为const{posts}=require('../temp');
i solved this issue by adding.env file and setting up env(environental) variable cloned project from github and was using dotenv which all adds in gitignore so we gets missed most of the time我通过添加 .env 文件并从 github 设置 env(environental) 变量克隆项目解决了这个问题,并且使用了 dotenv ,它都添加了 gitignore 所以我们大部分时间都错过了
I got faced the same issue and I solved it finally.我遇到了同样的问题,我终于解决了。 In my case I was performing
git push heroku main
which also main
isn't the default branch.在我的情况下,我正在执行
git push heroku main
这也是main
不是默认分支。 I had to go to master branch first(default branch), merge the code with my other branch and then heroku git:remote -a <repoName>
and git push heroku master
. I had to go to master branch first(default branch), merge the code with my other branch and then
heroku git:remote -a <repoName>
and git push heroku master
.
HOPE this can help!希望这能有所帮助!
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.