It is a global scoped variable in index.ts. projectPath is set in action callback as shown below:
const program = new Commander.Command(packageJson.name) // https://www.npmjs.com/package/commander#version-option .version(packageJson.version) // https://www.npmjs.com/package/commander#command-arguments .arguments('<project-directory>') // https://www.npmjs.com/package/commander#usage .usage(`${green('<project-directory>')} [options]`) // https://www.npmjs.com/package/commander#action-handler .action((name) => { projectPath = name // Here })
Let’s console.log it and see what its got.
There is no logged information about projectPath. What are we doing wrong? Your next immediate action is checking the documentation for Commander package and specifically, you are looking for action handler.
If you want to name your nextjs app as part of command npx create-next-app` you can change it to npx create-next-app my-app or you can configure the name as part of prompts. More on prompts in the upcoming articles.
Hey, my name is Ramu Narasinga. I study large open-source projects and create content about their codebase architecture and best practices, sharing it through articles, videos.