简体   繁体   中英

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '.data'

I ran into this error:

Error [ERR_MODULE_NOT_FOUND]: Cannot find package '.data' imported from **C:\Users\aushe\OneDrive\Documents\7_Semester\KANDEL\KandelReact\backend\seeder.js**

在这张图片上,您可以看到终端错误和完整日志

In the seeder script I call:

import mongoose from 'mongoose'
import dotenv from 'dotenv'
import colors from 'colors'
import users from '.data/users.js'
import products from './data/products.js'
import User from './models/userModel.js'
import Product from './models/productModel.js'
import Order from './models/orderModel.js'
import connectDB from './config/db.js'

I also checked for typos and found none in:

'.data/users.js'
'./data/products.js'

maybe I am missing a package? Please help: :)

I found the answer, it was indeed a typo.

I forgot to put a / in from of data/users.js

This is how it should look like, this is common knowledge though

import users from './data/users.js'
import products from './data/products.js'

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