node.js - 无法运行 npm install

标签 node.js magento npm

here它说要运行 npm install,但当我运行 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.

没有 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

最佳答案

您需要有一个 package.json 文件才能正常工作。

您可以通过运行来创建它:

npm init

另请参阅:

关于node.js - 无法运行 npm install,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/41895459/

相关文章:

node.js - 树莓派 mdns getaddrinfo 3008 错误

php - 确定是否启用了 Magento 模块

angular - 在 Angular 6 工作空间中安装 NPM 包

javascript - 在 promise 内返回 promise 时可能出现未处理的错误

javascript - 访问 Javascript 文件中传递的 EJS 变量

Magento数据库交易

node.js - 部署到 PAAS/Modulus 时如何忽略 npm 脚本

node.js - 如何在 Elastic Beanstalk 实例上运行任意 npm 脚本

javascript - 从 Javascript Promise 链返回值

php - 在 Magento 中获取状态为 'Complete' 的订单 ID