我无法安装并运行nodemon。我在ubuntu 16.04上运行node.js.我的api正在运行。安装的库是:
sven@sven-MS-7264:~/Projects/APIDemo$ npm -g ls --depth=0
/usr/lib
├── npm@5.6.0
└── pm2@2.9.3
npm ERR! invalid: minizlib@1.0.3 /usr/lib/node_modules/npm/node_modules/tar/node_modules/minizlib
sven@sven-MS-7264:~/Projects/APIDemo$ npm ls --depth=0
apidemo@1.0.0 /home/sven/Projects/APIDemo
├── body-parser@1.18.2
├── cookie-parser@1.4.3
├── debug@3.1.0
├── ejs@2.5.7
├── express@4.16.2
├── morgan@1.9.0
├── mysql@2.15.0
└── serve-favicon@2.4.5
但是当尝试全局安装nodemon时,我得到了这个:
sven@sven-MS-7264:~/Projects/APIDemo$ npm install -g nodemon
npm WARN registry Using stale data from https://registry.npmjs.org/ because the host is inaccessible -- are you offline?
npm WARN registry Using stale package data from https://registry.npmjs.org/ due to a request error during revalidation.
npm WARN checkPermissions Missing write access to /usr/lib/node_modules
npm ERR! path /usr/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
文件夹权限如下所示:
sven@sven-MS-7264:~/Projects$ ls -la
total 20
drwxrwxr-x 5 sven sven 4096 Feb 20 09:50 .
drwxr-xr-x 52 sven sven 4096 Feb 20 13:59 ..
drwx------ 7 sven sven 4096 Feb 20 16:27 APIDemo
如何安装和运行nodemon?
答案 0 :(得分:1)
如果您不是管理员,则无法安装全局模块。如果可以,请尝试使用sudo
运行命令
sudo npm install -g nodemon
您还可以通过删除-g
选项在本地文件夹中安装nodemon。