如何解决我该如何解决模块未定义的问题?
我有这两个文件。 第一个是在这里,我有一个包含我的操作的类,并且代码运行得很好,我看不到错误在哪里,我已经使用对象的对象进行了相同的编码,但不适用于对象的数组:>
class Lists {
constructor(list) {
this.list = list;
}
//funcao fetch item and return it
fetchItems() {
return this.lists;
}
//function add item
addItem(item) {
return (this.lists = [...this.lists,item]);
}
//function remove
removeItem(itemId) {
this.lists = this.lists.filter((list) => list.id !== itemId);
}
//function update Item
updatedItem(itemId,key,value) {
this.lists.map((element) => {
if (element.id === itemId) {
element[key] = value;
}
return element;
});
}//function clearList
clearList() {
return (this.lists = []);
}
}
module.exports = { Lists };
我有我的“文件,几乎可以存放所有我需要的东西
{
"name": "pkg","version": "1.0.0","description": "","main": "index.js","type": "module","scripts": {
"test": "jest"
},"author": "","license": "ISC","devDependencies": {
"@babel/core": "^7.11.6","@babel/preset-env": "^7.11.5","babel-cli": "^6.26.0","babel-jest": "^26.3.0","jest": "^26.4.2"
}
}
和我的babel文件
{
"presets": [
[
"@babel/preset-env",{
"targets": {
"node": "current"
}
}
]
]
}
但是它给了我这个错误“模块未定义”,我该怎么做才能解决这个问题。 这是完整的错误
module.export = {列表};
ReferenceError:模块未定义。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。