You can list what packages are installed globally in your system with npm -g list
—shorthand for npm --global list
—whereas you'd list the packages installed in an NPM project with npm list
.
Let's see an example of what the command might return.
npm -g list
# /opt/homebrew/lib
# ├── cross-env@7.0.3
# ├── http-server@14.1.1
# ├── node-gyp@9.3.1
# ├── npm@9.5.0
# ├── pm2@5.2.2
# ├── spoof@2.0.4
# ├── ts-node@10.9.1
# └── typescript@4.9.5
I found the following error while trying to execute PORT=4444 node ./bin/server.js
on my Node.js application.
SyntaxError: Cannot use import statement outside a module
I solved it by adding the following into the package.json
file of my NPM project.
"type": "module",
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.
How to install it globally?
npm install -g nodemon
Then you can use it anywhere as nodemon script.js
and, every time script.js
changes, the execution will restart with the new code, avoiding repetitive calls to node script.js
, for instance.