简体   繁体   English

找不到模块“护照”

[英]Cannot find module 'passport'

I am trying to start project with using Docker Compose at Ubuntu (16.04 LTS). 我正在尝试在Ubuntu(16.04 LTS)使用Docker Compose启动项目。 However, I have this issue with 'passport' module 但是,“护照”模块存在此问题

api_1            | [nodemon] 1.11.0
api_1            | [nodemon] to restart at any time, enter `rs`
api_1            | [nodemon] watching: *.*
api_1            | [nodemon] starting `node --debug server.js`
api_1            | Debugger listening on 127.0.0.1:5858
api_1            | module.js:472
api_1            |     throw err;
api_1            |     ^
api_1            | 
api_1            | Error: Cannot find module 'passport'
api_1            |     at Function.Module._resolveFilename  (module.js:470:15)
api_1            |     at Function.Module._load (module.js:418:25)
api_1            |     at Module.require (module.js:498:17)
api_1            |     at require (internal/module.js:20:19)
api_1            |     at Object.<anonymous> (/app/auth.js:4:16)
api_1            |     at Module._compile (module.js:571:32)
api_1            |     at Object.Module._extensions..js (module.js:580:10)
api_1            |     at Module.load (module.js:488:32)
api_1            |     at tryModuleLoad (module.js:447:12)
api_1            |     at Function.Module._load (module.js:439:3)
api_1            |     at Module.require (module.js:498:17)
api_1            |     at require (internal/module.js:20:19)
api_1            |     at Object.<anonymous> (/app/server.js:3:14)
api_1            |     at Module._compile (module.js:571:32)
api_1            |     at Object.Module._extensions..js (module.js:580:10)
api_1            |     at Module.load (module.js:488:32)
api_1            | [nodemon] app crashed - waiting for file changes 
                                before starting...

The main thing is that: 最主要的是:

1) Docker is running everything (and sets everything up, as mentioned in Dockerfile) 1)Docker正在运行所有内容(并进行了所有设置,如Dockerfile中所述)

2) There is passport dependency in package.json, in /app (where the server is launched). 2)在/ app(启动服务器的位置)的package.json中有护照依赖关系。

3) Passport as well as Node with npm are globally installed in Ubuntu (even though, Docker must set up all of these itself). 3)Passport以及带有npm的Node已在Ubuntu上全局安装(尽管Docker必须自己设置所有这些)。

4) I have const passport = require('passport'); 4)我的const passport = require('passport'); in the files where it is used. 在使用它的文件中。

Thus, I suspect that there are problems with some folder or file permissions (maybe even Docker's). 因此,我怀疑某些文件夹或文件权限(甚至是Docker的权限)存在问题。 How can I solve this problem? 我怎么解决这个问题?

Update: 更新:

I just had to completely reinstall the docker and docker-compose and everything worked perfect. 我只需要完全重新安装docker和docker-compose,一切工作就完美了。

Update: Another (probably, main) reason was that my Internet provider was blocking NPM, this is why I could not download (somehow) some of the packages. 更新:另一个(可能是主要的)原因是我的互联网提供商阻止了NPM,这就是为什么我无法(以某种方式)下载某些软件包的原因。 Thus, it worked out when I connected to another WiFi network. 因此,当我连接到另一个WiFi网络时,它就解决了。

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

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