Skip to content

use npm to start application #32

@GochoMugo

Description

@GochoMugo

As noted in the Readme:

The cartridge emulates the execution of npm start to start your application, so make sure your application
entrypoint is defined in your start script of your package.json file. See package.json in the provided
template or read the npm docs for more information.

Some advantages of using npm directly would include:

  • automatically add node_modules/.bin to $PATH:

In addition to the shell's pre-existing PATH, npm run adds node_modules/.bin to the PATH provided to
scripts. Any binaries provided by locally-installed dependencies can be used without the
node_modules/.bin prefix.

https://docs.npmjs.com/cli/run-script

With the assumption that this emulation was meant to be similar to the actual npm start, the start command (in bin/control#L6),

START_COMMAND=$(node -e "var p = require('$OPENSHIFT_REPO_DIR/package.json'); console.log(p.scripts.start);")

could be enhanced to run npm:

START_COMMAND="npm start"

Since this command will be executed in the repository's working directory, we can be sure it will find a package.json to look for the scripts in.

Side note:

  • I noticed this when I tried to run forever app.js, but the application crashed as the forever command could not be found ($PATH did not include node_modules/.bin)

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions