Hi Sorcerer, Did the tutorial ever instruct to create a base project structure before running the 'npm install' command? Such structure might include package.json and index.js files in the project directory. Then modifying that index.js would make sense.
The 'npm install' command is used for installing dependencies to an existing project (one that already has a package.json and source code). Npm installs the dependencies under 'node_modules' directory and that is exactly what you've found by investigating the colors package interals (some packages use index.js as entry point and some configure their own in package.json). However It is unorthodox to modify any files under 'node_modules' and causes your version of modules to be incompatible with what other developers expect them to be. On Saturday, July 23, 2016 at 8:58:47 PM UTC+3, Sorcerer Stone wrote: > > Hello all, > > Newbie in node.js. Reading a book and download projects to follow the > text. I understand the primary role of index.js file is the entry point for > a given project. But I have problems with this file. > > The first project in the book is to create a new directory (TestProject) > and download and install a project using the command "npm install colors" > in this directory. The book went on and show how to modify the index.js > file. > > After I ran the above command, a node_module folder is created in the root > directory (TestProject) and no other files beside this node_module exist in > the root directory. I attached screenshots for my questions. > > My question is where is index.js located? Should it be in the root > directory (TestProject) of this project or at least in colors's folder > where package.json is located (Path of Index.js 01.jpg)? Instead, I found > an index.js file buried in the subdirectory, the lib folder, within the > colors folder after the project was created (Path of Index.js 02.jpg). Is > this normal? > > In more complicated project, there are lots of index.js files created for > each dependent modules buried under node_module folder. For this simple > module, I would expect the location of index.js should be in the root > directory and not buried deep inside node_module's or colors' folder. But > this root directory (TestProject) is empty. Not sure what is the problem or > is this a problem at all. > > I am using Windows8, version of node.js is 4.4.7 (LTS version) and npm is > 2.15.8. > > Could I be running into this bug: > https://github.com/npm/npm/issues/5082 > > The above post said npm 2.15.8 should fix the missing index.js problem. > > Thanks in advance. > Sorcerer > -- Job board: http://jobs.nodejs.org/ New group rules: https://gist.github.com/othiym23/9886289#file-moderation-policy-md Old group rules: https://github.com/joyent/node/wiki/Mailing-List-Posting-Guidelines --- You received this message because you are subscribed to the Google Groups "nodejs" group. To unsubscribe from this group and stop receiving emails from it, send an email to nodejs+unsubscr...@googlegroups.com. To post to this group, send email to nodejs@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/nodejs/2a4ba5be-b122-4d41-a864-3833c686be41%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.