Hyperledger composer-cli error EACCESS - node.js

I'm starting to build an app on Hyperledger Composer following these instructions.
When I run :
$ npm install -g composer-cli
the package is correctly installed here :
/home/arnaud/.nvm/versions/node/v8.11.1/bin/composer
However when I try to run composer --version I have the following error EACCESS :
$ composer --version
/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/mkdirp/index.js:90
throw err0;
^
Error: EACCES: permission denied, mkdir '/home/arnaud/.composer/logs'
at Object.fs.mkdirSync (fs.js:885:18)
at Function.sync (/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/mkdirp/index.js:71:13)
at Object.exports.getLogger (/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/composer-common/lib/log/winstonInjector.js:76:20)
at Function._loadLogger (/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/composer-common/lib/log/logger.js:633:25)
at Function._setupLog (/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/composer-common/lib/log/logger.js:531:30)
at Function.getLog (/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/composer-common/lib/log/logger.js:508:20)
at Object.<anonymous> (/home/arnaud/.nvm/versions/node/v8.11.1/lib/node_modules/composer-cli/node_modules/composer-common/lib/businessnetworkmetadata.js:18:20)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
How could I solve this problem ? Many thanks

The above issue purely a permission issue, while installing composer-cli basically the folder v8.11.1 is own by different users, i.e. other than your user id. Hence we are facing this issue.
We need to change the owner and group of the v8.11.1 folder as follows.
Navigat to the folder v8.11.1 (/home/arnaud/.nvm/versions/node/v8.11.1) and then verify whether the folder is user and group are your user id (arnaud).
Surely the folder was not own by arnaud user and group. Change the folder user and group by using chown.

the logging error as RThatcher describes below - its trying to write to a logfile and part of that is to create the logs directory, but it doesn't have permissions. Did you previously do an install of Composer with 'sudo' ? what does ls -al /home/arnaud/.composer/* show (who owns the directories). I ask, because its strange that you can write everywhere else under your home directory (as you'd expect to, as arnaud) . Assuming of course, that you are running the composer --version command above, while logged in as 'arnaud' and not as another user?

Error: EACCES: permission denied, mkdir '/home/arnaud/.composer/logs'
This is the core error suggesting that you don't have permissions to create the logs folder on the /home/arnaud/.composer folder or that you do not have the rights to create the .composer folder in the /home/arnaud/ folder.
You should use a combination of ls -al , chmod and possibly chown Linux commands to investigate and resolve the permissions problem.

Related

Error: EACCES: permission denied NPM Ubuntu Server

I am running an Ubuntu EC2 server and followed the tutorial provided by AWS to install nvm and node, but when I try to run npm install, I'm thrown an error:
Error: EACCES: permission denied, access '/var/www/app'
Please try running this command again as root/Administrator.
The standard procedure with an EC2 Ubuntu service appears to only provide a ubuntu user with sudo privileges and no access to root so I tried to run sudo npm install, but I receive sudo: npm: command not found. The reason why I believe this is happening is because nvm is located at /home/ubuntu/.nvm/versions/node/v6.12.3/bin/node, which root might not have access to?
Is it possible to point root to the this directory location for this command or is there a different solution?
You're getting that error because you do not have write permission for your user on that /var/www/app.
You can follow the answer here to give permissions to that folder.
https://askubuntu.com/questions/749697/how-do-i-give-myself-access-to-var-www-to-create-and-edit-files-and-folders-in
You are getting the error about npm not being installed when you use sudo because it is not installed for the admin user. I would avoid installing node and npm through sudo though. Just go with changing the folder permissions.

npm update check failed

Last night I tried to update my node and npm, it seemed to have been successful, however ever since then I have been getting this same error any time I try and run any npm command.
I have tried uninstalling and re-installing npm, but cannot get past this error message below.
Node version: v8.3.0
Error message I am getting:
┌───────────────────────────────────────────────────────────────────┐
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /Users/veritystothard/.config │
└───────────────────────────────────────────────────────────────────┘
module.js:491
throw err;
^
Error: Cannot find module 'proto-list'
at Function.Module._resolveFilename (module.js:489:15)
at Function.Module._load (module.js:439:25)
at Module.require (module.js:517:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/local/lib/node_modules/npm/node_modules/config-chain/index.js:1:79)
at Module._compile (module.js:573:30)
at Object.Module._extensions..js (module.js:584:10)
at Module.load (module.js:507:32)
at tryModuleLoad (module.js:470:12)
at Function.Module._load (module.js:462:3)
I'm not sure what other details to include here, if anyone has had this issue before I'd appreciate your help. Thanks!
Following is the answer from github
Fix for windows, I got this message :
npm update check failed Try running with sudo or get access to the
local update config store via sudo chown -R $USER:$(id -gn $USER)
C:\Users.config
so I went on to C:\Users.config and deleted the
"configstore" folder. once I done this, next time a ran npm start, the
folder was re-generated, and error stopped
Fix for OSX:
After two hours of try-and-fail I managed to solve the issue as follows:
go to folder /usr/local/lib/node_modules/
right-click on the folder node_modules > go to Get Info
update the permissions > add yourself and administrator account and set "read and write" for both
run in the terminal "npm install packageName"
if you still get the error, go to the same folder /usr/local/lib/node_modules/ and within the folder node_modules, update in the same way the permissions for the new package folder
try to run again in the terminal "npm install packageName"
That worked for me! Hope it could help somebody.
I had the same issue on AWS server, i used this command to update the config permissions and the npm command worked smooth.
sudo chown -R $USER:$(id -gn $USER) ~/.config
If your are on macOS, you must update the config file. You just have to enter this command in your terminal:
sudo npm i -g npm
I have similar error after node updating so i just delete directory .config and this help.
Run below command from a command prompt
Step 1 : (If possible open cmd as administrator)
- npm install -g npm-check-updates
Step 2 :
- Open new command prompt and Create a new project
I got a Windows 10 environment:
For me, first I did make sure all node.exe instances killed:
taskkill /t /f /im node.exe
Then I've updated npm to the latest version using npm-check-updates
Finally, I deleted .config folder from user home C:\Users\<USERNAME>
That's solved my problem.
If you don't want to chown your entire .config directory (which contains configuration files from other programs), try:
sudo chown -R $USER:$(id -gn $USER) "/home/skaestle/.config/configstore/"
Try running the command prompt Run as administrator mode, if that not solved your issue delete the .config folder under c:\user\<name of the user>\ and then try running the command prompt Run as administrator mode.
I had the same error (npm update check failed) on a Centos 7 but not when installing node, just when loggin into the server and it was because there was no more space left. Deleted some files, updated the system and everything worked fine again.
Just in case somebody else comes to the same problem.
I have a fixed that worked for me on OSX Catalina:
-------------------------------------
/var/log/nodejs/nodejs.log
-------------------------------------
> node server.js
€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”€â”
│ npm update check failed │
│ Try running with sudo or get access │
│ to the local update config store via │
│ sudo chown -R $USER:$(id -gn $USER) /tmp/.config │
└──────────────────────────â”
I ran the following code in the terminal and as suggested here: sudo chown -R $USER:$(id -gn $USER) /tmp/.config & redeployed to my instance which still showed a degraded state.
I did this several times and this did not result in success.
Since I had a duplicate instance that was in the ready, so I didn't think it was a permissions problem on my local machine.
The following fix worked for me (please note that my code is deployed to ebs through AWS CodePipeline":
Delete package-lock.json from your express/node project.
Run npm i
git add && git commit -m "your commit msg" && git push
In your aws console, go to code pipeline and verify your code deployed successfully.
Navigate to Elastic Beanstalk. If your code pushed successfully, you should see your instance updating.
After this the state of your EBS environment should be in the ready state.
Hope this helps someone out.
worked for me after running below command
nvm use --delete-prefix version
Running the cmd with admin rights once was enough for me.
Just did npm version.
After that it worked again also without admin rights.
I did not delete anything.
{
npm: '6.13.6',
node: '12.14.1',
...
}
If the user does not have sudo rights in a unix environment, remember the user name you want to issue the command with (-> USER). Then use
su
Enter your root password. Then
chown -R USER:USER .config
Other .config folders that were created using root are also changed. In my case changing ~/.config/nvws owner did the job (chown -R THE USER YOU USE NPM WITH:THE USER YOU USE NPM WITH .config/nvm)
I'm a windows user. I solved mine by going to the /Users/<username> right clicking the .config folder then in properties un-ticked the read only and apply
run script to check for update
sudo npm install -g npm-check-updates
and later update using sudo npm
This issues come due to TWO reasons
You have no permission to read-write
Due to window settings folder is secured.
case 1st- just enable the read-write permission
case 2nd- if u have permission for read-write and still you facing the same issues, it means you system securities reject the request to write the file, because the file location is given in C drive
solution - JUST disable the firewall / Ransomware protection in windows 10. try again you will get the success.

StriderCD global post install fails on bower access to $HOME/.config $HOME/.cache

I am trying to work out the best way to install StriderCD globally. I installed node and npm via the global-enabled fork of nvm, and all paths are working fine for other builds, but none of them require a post install like this.
I've tried both sudo npm install -g strider and also just installing as root without sudo, but I always come across EACCESS errors on .config and .cache folders for bower in the post install step:
> strider#1.6.6 postinstall /usr/local/lib/node_modules/strider
> bower install --allow-root && npm run build
/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/mkdirp/index.js:89
throw err0;
^
Error: EACCES, permission denied '/home/ubuntu/.config'
Installed as root, root does not have permissions for it's own $HOME dir, which is very strange unless bower is creating dirs and files with wrong permissions. Can anyone explain this:
> strider#1.6.6 postinstall /usr/local/lib/node_modules/strider
> bower install --allow-root && npm run build
/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/configstore/index.js:56
throw err;
^
Error: EACCES, permission denied '/root/.config/configstore/bower-github.yml'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:500:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:352:15)
at Object.create.all.get (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/strider/node_modules/bower/lib/config.js:22:23)
at defaultConfig (/usr/local/lib/node_modules/strider/node_modules/bower/lib/config.js:11:24)
at Object.<anonymous> (/usr/local/lib/node_modules/strider/node_modules/bower/lib/index.js:40:32)
at Module._compile (module.js:460:26)
at Object.Module._extensions..js (module.js:478:10)
Using sudo as ubuntu user and tried chmod -R 777 $HOME/.config I get the same thing on $HOME/.cache! Sigh.
> strider#1.6.6 postinstall /usr/local/lib/node_modules/strider
> bower install --allow-root && npm run build
bower EACCES EACCES, permission denied '/home/ubuntu/.cache/bower/registry/bower.herokuapp.com/lookup'
Stack trace:
Error: EACCES, permission denied '/home/ubuntu/.cache/bower/registry/bower.herokuapp.com/lookup'
at Error (native)
at Object.fs.mkdirSync (fs.js:747:18)
at Function.sync (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-registry-client/node_modules/mkdirp/index.js:55:12)
at new Cache (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-registry-client/lib/util/Cache.js:21:16)
at RegistryClient.<anonymous> (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-registry-client/lib/lookup.js:163:35)
at Array.forEach (native)
at RegistryClient.initCache (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-registry-client/lib/lookup.js:150:34)
at RegistryClient._initCache (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-registry-client/Client.js:62:27)
at new RegistryClient (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-registry-client/Client.js:16:10)
at new PackageRepository (/usr/local/lib/node_modules/strider/node_modules/bower/lib/core/PackageRepository.js:17:28)
Console trace:
Error
at StandardRenderer.error (/usr/local/lib/node_modules/strider/node_modules/bower/lib/renderers/StandardRenderer.js:82:37)
at Logger.<anonymous> (/usr/local/lib/node_modules/strider/node_modules/bower/bin/bower:110:22)
at Logger.emit (events.js:107:17)
at Logger.emit (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/bower-logger/lib/Logger.js:29:39)
at /usr/local/lib/node_modules/strider/node_modules/bower/lib/commands/index.js:45:20
at _rejected (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/q/q.js:844:24)
at /usr/local/lib/node_modules/strider/node_modules/bower/node_modules/q/q.js:870:30
at Promise.when (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/q/q.js:1122:31)
at Promise.promise.promiseDispatch (/usr/local/lib/node_modules/strider/node_modules/bower/node_modules/q/q.js:788:41)
at /usr/local/lib/node_modules/strider/node_modules/bower/node_modules/q/q.js:556:49
System info:
Bower version: 1.4.1
Node version: 0.12.4
OS: Linux 3.13.0-48-generic x64
Why does bower insist on using $HOME/.config when I'm using --global and also installing with sudo? Is there a way to map this to a different path and make permissions proper? And when I su root -l to install, why does root not have permission to access files or create dirs inside it's own $HOME and/or $HOME/.config? Very confusing.
This is on a brand new updated 14.04 LTS AWS instance. What is the root cause of this error and is it my setup causing the problem or bad config on bower's or Strider's part?
The permissions of your filesystem do seem strange and should be investigated and repaired.
That said, the important part of that first stack trace is configstore, a piece of machinery used to cache or persist data to the disk. Needless to say it will try to write to those locations. That is a place to start.
Permissions problems are called out in the FAQ of the newer conf module, although it doesn't seem to apply to Linux.
In configstore, the config is stored in ~/.config (which is mainly a Linux convention) on all systems, while conf stores config in the system default user config directory. The ~/.config directory, it turns out, often have an incorrect permission on macOS and Windows, which has caused a lot of grief for users.
Would switching to conf fix the problem? Maybe, maybe not. Couldn't hurt to file an issue. It's a pretty trivial replacement. And you could certainly hack around inside of your node_modules to verify whether that fixes it for you.
Both configstore and conf respect the XDG_CONFIG_HOME envrionment variable. However they read it at slightly different times, the former at module require() time, the latter when its class is instantiated.
We should also challenge the assumption of processes running as a specific user (root), since Node programs can process.setuid() and this is relatively common amongst command line tools.
I would modify the various node_modules files being run and sprinkle in some...
console.log('User:', process.getuid());
console.log('Group:', process.getgid());
console.log('Effective user:', process.geteuid());
console.log('Effective group:', process.getegid());
This is useful because either bower or npm may be downgrading permissions at an inconvenient time. Or perhaps something within the npm run build script is doing so.
If you see the users or groups changing throughout the lifecycle of the program, that is a high potential area for bugs. Carefully check that the users or groups printed have full access to the paths that failed. Depending on the precise activity that is going on, it may be necessary to have execute (x) permissions on parent directories going all the way up to the root of the filesystem.

nodejs fs eacces permission

I've just run into a strange problem with fs reading a file.
I have node application run from a deployment manager (strongloop strong-pm) as the following user "strong-pm".
No matter what permissions I give to the file I'm trying to open throug the node app, I get
return binding.open(pathModule._makeLong(path), stringToFlags(flags), mode);
worker:1 Error: EACCES, permission denied '/root/my_dir/file.txt'
at Object.fs.openSync (fs.js:432:18)
at Object.fs.readFileSync (fs.js:286:15)
I've tried everything:
sudo chown -R strong-pm:strong-pm /root/my_dir
sudo chmod -R 777 /root/my_dir
sudo chmod 777 /root/my_dir/file.txt
adding the strong-pm to a group
then adding that group to the directory...
Still no luck.. any ideas?
Thanks!
System: Ubuntu 14.04 x64 on DigitalOcean
Rather than trying it inside node, try to switch to that user and read the file:
su strong-pm
cat /root/my_dir/file.txt
If that works, make sure node is running using that user.
Try this:
.{otherPATH}/root/my_dir/file.txt
It seemed like the issue was that the /root directory was protected and so subdirectories were not accessible by node somehow

EACCES error using Yeoman to install angular

I tried running
yo angular --coffee --minsafe
but I get this error
Error: EACCES, permission denied '/Users/Basil/.config/configstore/insight-yo.yml'
at Object.fs.openSync (fs.js:427:18)
at Object.fs.writeFileSync (fs.js:966:15)
at Object.create.all.set (/usr/local/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:39:7)
at Object.Configstore (/usr/local/lib/node_modules/yo/node_modules/insight/node_modules/configstore/configstore.js:30:11)
at new Insight (/usr/local/lib/node_modules/yo/node_modules/insight/lib/insight.js:20:16)
at Object.<anonymous> (/usr/local/lib/node_modules/yo/bin/yo:26:15)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
I have checked the issues on Github and seen npm / yeoman install generator-angular without sudo but can't seem to get it to work
node v0.10.17
npm v1.2.10
find / -name 'yeoman'
/Users/Basil/.node/node_modules/.bin/yeoman
/Users/Basil/.node/node_modules/yeoman
/Users/Basil/.node/node_modules/yeoman/bin/yeoman
/Users/Basil/.node/node_modules/yeoman/node_modules/yeoman-generators/lib/generators/yeoman
/Users/Basil/.npm/yeoman
/Users/Basil/.npm/yeoman/0.9.6/package/bin/yeoman
/Users/Basil/.npm/yeoman-generators/0.9.5/package/lib/generators/yeoman
I was able to fix this issue with this:
Sudo chown Basil /Users/Basil/.config/configstore/update-notifier-yo.yml
If you run into this issue, try this out, replacing "Basil" with your username
You can just use npm cache clean and bower cache clean.
Sudo chown Basil /Users/Basil/.config/configstore/update-notifier-yo.yml (Remove trailing chown) Replace Basil with your username.
Sudo chown <yourusername> /Users/<yourusername>/.config/configstore/update-notifier-yo.yml Keepinging in mind your username does not include the dollar sign.
This corrected the Error when running Yeoman:
EACCES, permission denied '/Users/<yourusername>/.config/configstore/update-notifier-yo.yml'
If the above doesn't work simply delete all files in the /Users/USER_NAME/.config/configstore/ directory and run yo angular again. Replace USER_NAME with your user name.
I just fixed it in Windows.
I have done three things, which one have fixed it I am not sure.
Run cmd prompt as administrator.
takeown /? this command is equivalent to chown (linux) but for windows.
cacls -cacls /E /T /G :F
simply go in $USER /Users/calvin/.config/configstore/ and make files unhidden.
it worked for me like charm.
I have been trying to fix this since many days.
This is probably too late to answer but in order to help others, changing both permissions (chmod) and owner (chown) is what worked for me on Ubuntu:
sudo chmod g+rwx /home/myusername/.config/configstore
sudo chown myusername /home/myusername/.config/configstore
This one worked for me :
//Update npm to the latest version. Works for to upgrade 1.x to 2.x.
$ npm install -g npm stable
// Assign group permissions to the parent directory.
$ chmod g+rwx /root /root/.config /root/.config/configstore
you can simply remove the .config folder from user home directory
rm -rf /home/user/.config then run sudo yo which will create .config again and reset previous faulty configuration. Mine is working fine after apply this approach.

Resources