Skip to content

if no file is specified use package.json's main property #14

Closed
@dylang

Description

@dylang

A simple short for lazy developers - if no command line arguments and package.json exist then use the main property.

EDIT: was use index.js

Activity

visnup

visnup commented on Mar 18, 2011

@visnup

or check for a package.json file in the directory and use it's main entry.

dylang

dylang commented on Mar 19, 2011

@dylang
Author

I like that even better. Updating description...

remy

remy commented on Apr 23, 2011

@remy
Owner

On it.

reopened this on Apr 24, 2011
remy

remy commented on May 1, 2011

@remy
Owner

Why reopened? This change was applied in the last change to nodemon and released to npm...

dylang

dylang commented on May 2, 2011

@dylang
Author

i reopened because i didn't see the change in the changelist associated with this but i must have done something wrong because my comment wasn't included and the feature works now.

thanks a ton for adding it!

remy

remy commented on May 2, 2011

@remy
Owner

The change was here if you're interested: 88269ba#L1R129

visnup

visnup commented on May 25, 2011

@visnup

<3 <3 <3 <3

benjamine

benjamine commented on Oct 7, 2014

@benjamine

this doesn't work for me, main is not intended to start the app, it would be nicer if we looked for a npm start (ie. scripts.start in package.json), and run that command as using npm --exec

FagnerMartinsBrack

FagnerMartinsBrack commented on Nov 30, 2023

@FagnerMartinsBrack

Makes no sense, this is ridiculous. Using "main" violates the principle of least astonishment. Node CLI DOES NOT uses "main" for starting the server, that's used for import clients not server start clients.

I'm using the same project as a import to other bounded contexts to be able to execute code owned by one domain boundary and the server startup that uses npm run dev to start a specific server file using nodemon start-server. My npm start uses node start-server which works.

How do I prevent this completely unexpected and erroneous behaviour? Any workaround?

Please guys, avoid trying to do magic, I beg you. Nodemon is a great tool don't destroy it. I can open a PR reverting this if you want.

This needs urgent reopening. Sorry if my tone sounds too demanding, just to express the frustration, I hope you don't take personally.

Great work with nodemon!

EDIT: solution was to use node --watch-path=./src start-server in NodeJS v18[1]. No workaround found.

1: https://nodejs.org/api/cli.html#--watch-path

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @visnup@remy@dylang@benjamine@FagnerMartinsBrack

        Issue actions

          if no file is specified use package.json's main property · Issue #14 · remy/nodemon