在节点中找不到模块的错误



在节点中找不到模块。我使用查询器在节点收集信息,以生成一个读取我与该信息。我觉得我正确地调用模块,它应该工作(著名的最后一句话),但它给了我一个错误说

错误:找不到模块'./createMarkdown'.

试着改变我叫它的方式,就像'createMarkdown',它仍然给出相同的错误。

// This is the index.js file that im running using node index.js
const readMeLayout = require('./createMarkdown');
const fs = require('fs');
const inquirer = require('inquirer');
const questions = [
{
type: 'input',
name: 'name',
message: 'What is your name?',
validate: (value) => {
if (value) { return true }
else { return "Name Required" }
}
},
{
type: 'input',
name: 'title',
message: 'What is the title of your project?',
validate: (value) => {
if (value) { return true }
else { return "Title Required" }
}
},
{
type: 'input',
name: 'description',
message: 'What would you describe your project as?',
validate: (value) => {
if (value) { return true }
else { return "Description Required" }
}
},
{
type: 'input',
name: 'install',
message: 'What are your installation instructions?',
},
{
type: 'input',
name: 'usage',
message: 'How was your project designed to be used?',
},
{
type: 'input',
name: 'contributing',
message: 'How can one contribute to your project?',
},
{
type: 'list',
name: 'license',
message: 'Provide license information.',
choices: ["MIT", "Mozilla_Public", "GNU_Affero General Public Licence v3", "GNU_General Public License v2", "GNU_Lesser General Public License v2.1", "Apache_2.0",]
},
{
type: 'input',
name: 'github',
message: 'Enter your GitHub Username.',
validate: (value) => {
if (value) { return true }
else { return "Github required" }
}
},
{
type: 'input',
name: 'questions',
message: 'Enter your email so others can reach you if they have questions.',
},
];
function writeToFile(fileName, data) {
fs.writeFile(fileName, data, (err) => {
if (err) throw err;
});
console.log('README created.');
}
function init() {
inquirer.prompt(questions)
.then((answers => {
const readme = readMeLayout(answers);
writeToFile("README.md", readme);
}));
}
init();
// this is the module for the layout of the readme file
const readMeLayout = data => {
const { title, description, usage, installation, license, contributing, name, github, email } = data;
return `
# ${title}
-------------------
## Table of Contents  
----------------------
- [Description](#description) 
- [Usage](#usage)  
- [Installation](#installation)  
- [License](#license)  
- [Contributing](#contributing)  
- [Questions](#questions)  

### Description  
-------------------
${description}
### Usage  
------------
${usage}

### Installation  
-------------------
${installation}
### License
--------------
![${license}](https://img.shields.io/badge/license-${license}-blue)
### Contributing 
------------------
### Contact Information
-------------------------
### Github: [${name}](https://github.com/${github})
#### Email: ${email}
`;
}
module.exports = readMeLayout; 

我明白了。我已经在错误的目录显示节点模块,但没有安装查询器在工作目录

相关内容

最新更新