Node.js:键入错误:Notes.addNote不是函数
根据Node.js上的教程,获取一个错误 app.js: notes.js: 我得到的错误是变量Node.js:键入错误:Notes.addNote不是函数,node.js,Node.js,根据Node.js上的教程,获取一个错误 app.js: notes.js: 我得到的错误是变量addNote、getAll和readNote不是函数。在我看来,app.js中的变量似乎没有从notes.js中读取。但是“Starting notes.js”实际上正在阅读和打印。 这里有什么问题?谢谢有个打字错误。 应该是 有一个打字错误。 应该是 非常感谢。问题是我也有同样的拼写错误,谢谢。非常感谢。问题是我也有同样的拼写错误,谢谢 console.log('Starting app.js')
addNote
、getAll
和readNote
不是函数。在我看来,app.js
中的变量似乎没有从notes.js
中读取。但是“Starting notes.js”
实际上正在阅读和打印。
这里有什么问题?谢谢有个打字错误。
应该是
有一个打字错误。
应该是
非常感谢。问题是我也有同样的拼写错误,谢谢。非常感谢。问题是我也有同样的拼写错误,谢谢
console.log('Starting app.js');
const fs = require('fs');
const _ = require ('lodash');
const yargs = require('yargs');
const notes = require ('./notes.js');
const argv = yargs.argv;
var command = process.argv[2];
console.log ('Command:' , command);
console.log ('Process: ', process.argv);
console.log('Yargs: ', argv)
if (command === 'add') {
notes.addNote (argv.title, argv.body);
}
else if (command === 'list') {
notes.getAll();
}
else if (command === 'read') {
notes.readNote(argv.title);
}
else if (command === 'delete') {
console.log ('command deleted');
}
else {
console.log('command not recognized');
}
console.log('Starting notes.js');
var addNote = function (title, body) {
console.log ('Adding note', title, body);
};
var getAll =() => {
console.log ("getting all notes");
};
var readNote = function(title) {
console.log("I am reading note", title);
}
module.export = {
addNote,
getAll,
readNote
};
module.exports = {
addNote,
getAll,
readNote
};