簡體   English   中英

CentOS,節點找不到模塊

[英]CentOS, node cannot find module

我在MacOS上很好地運行了index.js。
今天,我使用git && Github將節點項目部署到CentOS7。該項目向我顯示了錯誤。 node index.js我看到錯誤Cannot find module 'Joi'

npm list --depth=0

npm list --depth=0
nodeMongoVdily@1.0.0 /root/newNode
├── express@4.16.4
├── joi@14.3.1
└── mongoose@5.4.17

誰知道原因?

我在Google和Stack Overflow上搜索了半個小時。 我沒有找到解決該錯誤的方法。

Error: Cannot find module 'Joi'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
at Function.Module._load (internal/modules/cjs/loader.js:520:25)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/root/newNode/model/genre.js:2:13)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)
at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
at Function.Module._load (internal/modules/cjs/loader.js:543:3)
at Module.require (internal/modules/cjs/loader.js:650:17)
at require (internal/modules/cjs/helpers.js:20:18)
at Object.<anonymous> (/root/newNode/routes/genre.js:5:29)
at Module._compile (internal/modules/cjs/loader.js:702:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
at Module.load (internal/modules/cjs/loader.js:612:32)

https://discuss.circleci.com/t/error-uncaughtexception-cannot-find-module-joi/24949/2

我找到了答案。

您不會相信,但我將代碼從
讓Joi = require('Joi')

讓joi = require('joi')
所有小寫​​字母,都令人驚訝地修復了構建。
但是我猜想它在本地有效:thinking:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM