简体   繁体   中英

internal/modules/cjs/loader.js:968 throw err; ^ Error: Cannot find module '../../temp'

My Node.js app is throwing the error below:_

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.

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'); I changed it to 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

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. 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!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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