В файле module.js находится модуль моего типа потока, я пытаюсь применить код в моем файле form.js, импортировав его из модуля узла "module.js", но при этом выдается ошибка Uncaught error: Cannot find module "./src/module.js". Я не уверен, откуда исходит ошибка, так как это единственная ошибка, которую я получил.
module.js
function capitalizeFirstLetter(data: string) {
return data.charAt(0).toUpperCase() + data.slice(1);
}
function titleize (data: String) {
if (data === null || data === undefined) {
return "";
}
let cleanTitle = data.replace(/[ \-_]+/g, " ");
let words = cleanTitle.replace(/([A-Z])/g, " $&").trim().split(" ");
let capitalizedWords = words.map(word => capitalizeFirstLetter(word));
return capitalizedWords.join(" ").toString();
}
module.exports = {
titleize: titleize
};
form.js
import app from "my-app";
/* code here */
render() {
console.log(app.titleize("sample log"));
}