简体   繁体   中英

npm install command works fine as root user but throws error if command is executed as jenkins user

I am trying to run npm install in my Linux centos machine as jenkins but it is failing with:

npm WARN tar ENOENT: no such file or directory, lstat '/home/jenkins/workspace/'job name'/Scheduler/scheduler-component/node_modules/ "

But if I run npm install as root this works fine.

Why does this happen and how can I resolve it?

The problem related to the $PATH and Global / Local, npm expect it to be there and its not, run as root using the root $PATH so files exists, the npm

This Tutorial explains it

It means that when doing something like fs.lstat('/home/ubuntu/.npm/iconv-lite/0.2.11/package/encodings/table/gbk.js', ...), npm received ENOENT error. Which means the file was missing, but npm expected it to be there.

if not try to :

  1. Ensure dependencies described correctly on package.json Just type npm install and hit Enter.
  2. Check issue still exists. and If issue not resolved, continue these methods.
  3. type npm cache clean and hit Enter type sudo npm install -g npm and hit Enter.
  4. Retry npm install and hit Enter.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM