Can't run npm install

99封情书 提交于 2021-02-11 08:01:09

问题


In here it says to run npm install, but I get this error when I run sudo npm install.

sudo npm install
npm WARN enoent ENOENT: no such file or directory, open '/var/www/html/mg/package.json'
npm WARN mg No description
npm WARN mg No repository field.
npm WARN mg No README data
npm WARN mg No license field.

without sudo:

npm install
npm WARN enoent ENOENT: no such file or directory, open '/var/www/html/mg/package.json'
npm WARN mg No description
npm WARN mg No repository field.
npm WARN mg No README data
npm WARN mg No license field.
npm ERR! Linux 4.4.0-59-generic
npm ERR! argv "/usr/bin/nodejs" "/usr/bin/npm" "install"
npm ERR! node v4.2.6
npm ERR! npm  v3.5.2
npm ERR! path /var/www/html/mg/node_modules/.staging
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall mkdir

npm ERR! Error: EACCES: permission denied, mkdir '/var/www/html/mg/node_modules/.staging'
npm ERR!     at Error (native)
npm ERR!  { [Error: EACCES: permission denied, mkdir '/var/www/html/mg/node_modules/.staging']
npm ERR!   errno: -13,
npm ERR!   code: 'EACCES',
npm ERR!   syscall: 'mkdir',
npm ERR!   path: '/var/www/html/mg/node_modules/.staging' }
npm ERR! 
npm ERR! Please try running this command again as root/Administrator.

npm ERR! Please include the following file with any support request:
npm ERR!     /var/www/html/mg/npm-debug.log

回答1:


You need to have a package.json file for that to work.

You can create it by running:

npm init

See also:

  • https://docs.npmjs.com/cli/init
  • https://docs.npmjs.com/files/package.json


来源:https://stackoverflow.com/questions/41895459/cant-run-npm-install

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!