Nodemon on IBM i

Issue #45 resolved
Former user created an issue

Hi, it is possibile to use nodemon on IBM i?

I tried to install it globally with npm install -g nodemon (with PASE) but I get the error:

/QOpenSys/usr/bin/-sh: nodemon: not found.

It is simply not supported or I'm doing it wrong?

Thank you very much

Comments (7)

  1. Musse

    Hello

    Can you provide the version of of IBM i you are using as well the version of Node.js?

    I will try to replicate the issue.

  2. Jesse G

    I think you'll need to adjust your PATH as alluded to here: https://bitbucket.org/ibmi/opensource/src/master/docs/troubleshooting/5733OPS_MIGRATION.md

    Namely: To switch the default version of Node.js for a specific user, place /QOpenSys/pkgs/lib/nodejs<version>/bin/node at the beginning of the user's PATH environment variable

    The issue is that global installs don't place the executables in the system-wide executable path because of the coexistence of multiple major versions of Nodejs (so for instance, node 8 globals don't conflict with node 10 globals).

    You should have a nodemon executable at /QOpenSys/pkgs/lib/nodejs10/bin/nodemon, for instance, if you're running Node 10.

    If this resolves your problem, we should leave this issue open as a documentation issue, since this is not really stated anywhere (and it's important!)

  3. Glucab

    Hi and thanks for the replies.

    Yes I can launch the nodemon from /QOpenSys/pkgs/lib/nodejs8/bin/nodemon and it works if I launch nodemon and the server.js with the complete path.

    I've added the PATH temporary and now I can start nodemon from everywhere :)

    nodemon
    [33m[nodemon] 1.18.11 [39m
    [33m[nodemon] to restart at any time, enter rs [39m [33m[nodemon] watching: . [39m
    [32m[nodemon] starting node server.js [39m

    Still, it doesn't automatically restart the node server when I change the server.js file, I have to manually input "rs" to restart the server :(

    My version of node is 8.15 and the version of IBM i is V7R3

  4. Jesse G

    This may be related to some differences in how fs.watch() APIs work on IBM i. Assigning this to @mengxumx, who has dealt with such issues, for first-pass analysis.

    This may eventually be best pursued in an issue to https://github.com/paulmillr/chokidar which is used by nodemon to watch for filesystem changes. But let's wait for @mengxumx's analysis.

  5. mengxumx Account Deactivated

    There are two offical file system monitoring API in Node.js--

    • fs.watch(filename[, options][, listener])
    • fs.watchFile(filename[, options], listener)

    fs.watchFile is a basic function, which queries (polls) the specified files' status every 5 seconds (by default). Most system (including IBM i) support this. It is slower, and resource consuming. fs.watch is an advanced function, which get notified immediately when the specified files' status changed. Unfortunately some platform (including IBM i) does not support it. What's more, it is unstable (report twice, not persistent, etc)

    What nodemon did is the 3rd function, an enhanced fs.watch, which has not been adopted by Node.js officially yet.

    I have not checked the code of chokidar yet. For now I am afraid if we can port the 3rd function to IBM i.

  6. mengxumx Account Deactivated

    For a workaround, we can use the legacyWatch: true which enables Chokidar's polling.

    Via the CLI, use either --legacy-watch or -L for short:

    bash-4.4$ /QOpenSys/pkgs/lib/nodejs8/bin/nodemon -L index.js
    [nodemon] 1.18.11
    [nodemon] to restart at any time, enter `rs`
    [nodemon] watching: *.*
    [nodemon] starting `node index.js`
    Server running at http://0.0.0.0:8083
    [nodemon] restarting due to changes...
    [nodemon] restarting due to changes...
    [nodemon] starting `node index.js`
    Server running at http://0.0.0.0:8080
    

    Ref -> https://github.com/remy/nodemon#application-isnt-restarting

  7. Log in to comment