Notice
Recent Posts
Recent Comments
Link
์ผ | ์ | ํ | ์ | ๋ชฉ | ๊ธ | ํ |
---|---|---|---|---|---|---|
1 | 2 | 3 | 4 | 5 | ||
6 | 7 | 8 | 9 | 10 | 11 | 12 |
13 | 14 | 15 | 16 | 17 | 18 | 19 |
20 | 21 | 22 | 23 | 24 | 25 | 26 |
27 | 28 | 29 | 30 | 31 |
Tags
- styled-components
- ํด๋ก ์ฝ๋ฉ
- reduce
- ํฌํธํด๋ฆฌ์ค
- ๋ ธ๋ง๋์ฝ๋
- sort
- ๊ฐ๋ฐ์๋ถํด๋ฝ
- ํ์ ์คํฌ๋ฆฝํธ
- onsnapshot
- ๋ผ์ดํธ๋ชจ๋
- firebase
- ๋คํฌ๋ชจ๋
- ๋ฐ์ํ์คํจ2
Archives
- Today
- Total
rigood
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string. ๋ณธ๋ฌธ
๐ป ๋ฐฑ์๋/MongoDB
MongooseError: The `uri` parameter to `openUri()` must be a string, got "undefined". Make sure the first parameter to `mongoose.connect()` or `mongoose.createConnection()` is a string.
rigood 2023. 7. 4. 15:22
mongoose.connecet ๋ฉ์๋๋ฅผ ์ด์ฉํ์ฌ mongoDB์ ์ฐ๊ฒฐํ๋ ๊ณผ์ ์์ ์๋ฌ๊ฐ ๋ฐ์ํ๋ค.
connect ๋ฉ์๋์ ์ฒซ๋ฒ์งธ ์ธ์๋ ๋ฐ๋์ string์ด์ด์ผ ํ๋๋ฐ
ํ์ฌ ๊ฐ์ undefined์ฌ์ ๋ฐ์ํ ์๋ฌ๋ก,
process.env.DB_URL ๊ฐ์ ์ฝ์ด์ค์ง ๋ชปํด ๊ฐ์ด undefined๊ฐ ๋ ๊ฒ์ด๋ค.
node.js์์ process.env ํ๊ฒฝ๋ณ์ ๊ฐ์ ์ฝ์ด์ค๋ ค๋ฉด dotenv๋ผ๋ ๋ผ์ด๋ธ๋ฌ๋ฆฌ๋ฅผ ์ค์นํด์ผ ํ๋ค.
npm i dotenv
์ค์น ํ server.js์์ dotenv๋ฅผ ์ค์ ํด์ค๋ค.
์ด๋ ๊ฒ ํ๋๋ฐ๋ ๊ณ์ ์ค๋ฅ๊ฐ ๋ฌ๋ค๋ฉด, .env ํ์ผ์ด ๋ฃจํธ ํด๋์ ์์นํด์๋์ง ํ์ธํด๋ณด์. .env ํ์ผ์ด src ํด๋ ์์ ์์ผ๋ฉด ์ ์์ ์ผ๋ก ์คํ๋์ง ์๋๋ค.
Comments