1. 程式人生 > 實用技巧 >nodemon command is not recognized in terminal for node js server

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 [email protected]: Please update to v 2.2.x
C:\Users\clu\AppData\Roaming\npm\nodemon -> C:\Users\clu\AppData\Roaming\npm\node_modules\nodemon\bin\nodemon.js

> [email protected] postinstall C:\Users\clu\AppData\Roaming\npm\node_modules\nodemon
> 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\nodemon\node_modules\chokidar\node_modules\fsevents):
npm WARN notsup SKIPPING OPTIONAL DEPENDENCY: Unsupported platform for [email protected]: wanted {"os":"darwin","arch":"any"} (current: {"os":"win32","arch":"x64"})

+ [email protected]
added 119 packages from 53 contributors in 34.983s