Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

JavaScript Build a REST API With Express Building API Routes in Express Create an Express App

Tom Settle
Tom Settle
5,127 Points

When running default npm init - can we not name it app.js anymore? I am getting error for not finding index.js.

Looks like npm init now has index.js as the default for the main js file

2 Answers

Jennifer Nordell
seal-mask
STAFF
.a{fill-rule:evenodd;}techdegree
Jennifer Nordell
Treehouse Teacher

Tom Settle When you first run npm init it will take you through the setup of the npm package. Many of these are options that you have likely sort of just hit "Enter" and skipped through up until now. One of them looks like this:

entry point: (index.js)

If you do not enter a value here, it will default to index.js.

You will have a package.json file that may look similar to this:

{
  "name": "html",
  "version": "1.0.0",
  "description": "",
  "main": "index.js",
  "dependencies": {
    "normalize": "^0.3.1"
  },
  "devDependencies": {},
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}

You can edit the "index.js" directly in that file and have it point to the main.js if you wish :smiley:

Hope this helps! :sparkles:

you get error if only the script your running is different than the package.json. however if you have nodemon installed as your dev setting then you change your main to app.js or what ever.