zoukankan      html  css  js  c++  java
  • nodemon command is not recognized in terminal for node js server

    nodemon command is not recognized in terminal for node js server

    You need to install it globally

    npm install -g nodemon
    # or if using yarn
    yarn global add nodemon
    

    And then it will be available on the path (I see now that you have tried this and it didn't work, your path may be messed up)

    If you want to use the locally installed version, rather than installing globally then you can create a script in your package.json

    "scripts": {
        "serve": "nodemon server.js"
      },
    

    and then use

    npm run serve
    

    optionally if using yarn

    # without adding serve in package.json
    yarn run nodemon server.js
    # with serve script in package.json
    yarn run serve
    

    npm will then look in your local node_modules folder before looking for the command in your global modules

    安装

    npm install -g nodemon
    npm WARN deprecated fsevents@2.1.3: Please update to v 2.2.x
    C:UserscluAppDataRoaming pm odemon -> C:UserscluAppDataRoaming pm ode_modules odemonin odemon.js

    > nodemon@2.0.6 postinstall C:UserscluAppDataRoaming pm ode_modules odemon
    > node bin/postinstall || exit 0

    Love nodemon? You can now support the project via the open collective:
    > https://opencollective.com/nodemon/donate

    npm WARN optional SKIPPING OPTIONAL DEPENDENCY: fsevents@~2.1.2 (node_modules odemon ode_moduleschokidar ode_modulesfsevents):
    npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for fsevents@2.1.3: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

    + nodemon@2.0.6
    added 119 packages from 53 contributors in 34.983s

    https://github.com/remy/nodemon

    Monitor for any changes in your node.js application and automatically restart the server - perfect for development

    nodemon is a tool that helps develop node.js based applications by automatically restarting the node application when file changes in the directory are detected.

    nodemon does not require any additional changes to your code or method of development. nodemon is a replacement wrapper for node. To use nodemon, replace the word node on the command line when executing your script.

    Monitoring multiple directories

    By default nodemon monitors the current working directory. If you want to take control of that option, use the --watch option to add specific paths:

    nodemon --watch app --watch libs app/server.js

    Now nodemon will only restart if there are changes in the ./app or ./libs directory. By default nodemon will traverse sub-directories, so there's no need in explicitly including sub-directories.

    Don't use unix globbing to pass multiple directories, e.g --watch ./lib/*, it won't work. You need a --watch flag per directory watched.

    Specifying extension watch list

    By default, nodemon looks for files with the .js, .mjs, .coffee, .litcoffee, and .json extensions. If you use the --exec option and monitor app.py nodemon will monitor files with the extension of .py. However, you can specify your own list with the -e (or --ext) switch like so:

    nodemon -e js,pug

    Now nodemon will restart on any changes to files in the directory (or subdirectories) with the extensions .js, .pug.

    nodemon --watch src -e html,vue,js,scss,css build/build.js

  • 相关阅读:
    gcc开启C99或C11标准支持
    数组作为参数的四种声明方式
    [BZOJ 2654]tree(陈立杰)
    [HNOI 2014]道路堵塞
    [ZJOI 2006]书架
    [NOI 2010]超级钢琴
    汇编语言语法
    [洛谷P1714]切蛋糕
    [洛谷P1440]求m区间内的最小值
    [NOIP2016 TG D2T3]愤怒的小鸟
  • 原文地址:https://www.cnblogs.com/chucklu/p/14177984.html
Copyright © 2011-2022 走看看