Issues installing fabric-sdk-rest - npm

I am trying to install hyperledger fabric sdk rest server. I have cloned fabric-sdk-rest repo and installed the prerequisites but when trying to run "npm link" in packages/loopback-connector-fabric I get the following error:
npm ERR! path /usr/lib/node_modules/loopback-connector-fabric
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall unlink
npm ERR! Error: EACCES: permission denied, unlink '/usr/lib/node_modules/loopback-connector-fabric'
npm ERR! { Error: EACCES: permission denied, unlink '/usr/lib/node_modules/loopback-connector-fabric'
npm ERR! stack: 'Error: EACCES: permission denied, unlink \'/usr/lib/node_modules/loopback-connector-fabric\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'unlink',
npm ERR! path: '/usr/lib/node_modules/loopback-connector-fabric' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2018-02-12T22_24_45_379Z-debug.log
This is what happens if I run it with sudo:
> pkcs11js#1.0.13 install /home/user/Documents/fabric-sdk-rest/packages/loopback-connector-fabric/node_modules/pkcs11js
> node-gyp rebuild
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/home/user/Documents/fabric-sdk-rest/packages/loopback-connector-fabric/node_modules/pkcs11js/build'
gyp ERR! System Linux 4.8.0-36-generic
gyp ERR! command "/usr/bin/node" "/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /home/user/Documents/fabric-sdk-rest/packages/loopback-connector-fabric/node_modules/pkcs11js
gyp ERR! node -v v9.5.0
gyp ERR! node-gyp -v v3.6.2
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! pkcs11js#1.0.13 install: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the pkcs11js#1.0.13 install script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/user/.npm/_logs/2018-02-12T22_26_40_864Z-debug.log
This is done in Ubuntu 16.04. What am I doing wrong?

I was facing this errors too. After a while trying all kind of insane things to get it running I came into account that the problem was I was installing npm modules as superuser globally. This conflicts with hyperledger*.
Solutions is $: sudo npm uninstall -g *** for every module you just installed as superuser.
Then you need to install the modules not as superuser. This are some advices.
If installing Hyperledger Composer using Linux, be aware of the following advice:
Login as a normal user, rather than root.
Do not su to root.
When installing prerequisites, use curl, then unzip using sudo.
Run prereqs-ubuntu.sh as a normal user. It may prompt for root password as some of it's actions are required to be run as
Do not use npm with sudo or su to root to use it.
Avoid by all means installing node modules globally as root.
If you're running on Ubuntu, you can download the prerequisites using the following commands:
curl -O https://hyperledger.github.io/composer/prereqs-ubuntu.sh
chmod u+x prereqs-ubuntu.sh
Next run the script - as this briefly uses sudo during its execution, you will be prompted for your password.
$: ./prereqs-ubuntu.sh
This is the best way
Or you can visit this page and follow the prereqs installation guide.
Prerequisites for Ubuntu
and finally follow this link to continue the installation it works just fine.
Install development tools
This is the latest update
Hope this helps

Related

VS code setting up development tools ERR! permission

I'm new to using VS code, I'm trying to install Hubspot tools using the npm install -g #hubspot/cli
But when i do i get the following
Thorins-MBP:Practice project thorinphoenix$ npm install -g #hubspot/cli
npm ERR! code EACCES
npm ERR! syscall mkdir
npm ERR! path /usr/local/lib/node_modules/#hubspot
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#hubspot'
npm ERR! [Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/#hubspot'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'mkdir',
npm ERR! path: '/usr/local/lib/node_modules/#hubspot'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/thorinphoenix/.npm/_logs/2022-05-18T13_17_18_580Z-debug-0.log
Thorins-MBP:Practice project thorinphoenix$
I used the best fix on this page and it worked. How to fix EACCES issues with npm install
Enter this into terminal:
sudo chown -R `whoami` ~/.npm
sudo chown -R `whoami` /usr/local/lib/node_modules

Getting No such file or directory: 'ganache-cli' error

I installed ganache-cli using npm install -g ganache-cli, however I am running into a No such file or directory: 'ganache-cli error when trying to run it. When calling echo $PATH, I see ~/.npm-global/bin, which contains the ganache-cli file, so I am confused as to what the issue could be. Any help is greatly appreciated.
For reference, I am using zsh on MacOS.
ganache-cli is now deprecated. You might see the following npm-warning:
npm WARN deprecated ganache-cli#6.12.2: ganache-cli is now ganache; visit https://trfl.io/g7 for details
Use npm install -g ganache.
Use sudo npm install -g ganache if you get some error like this:
$ npm install -g ganache
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/ubuntu/.npm/_logs/2022-06-23T12_37_16_476Z-debug.log

How do you install Firebase tools in a Gitlab CI Runner?

I'm having some trouble configuring Gitlab CI to run firebase emulators. In particular, it's failing to install firebase-tools. This is the relevant part of my config
unit-test-job: # This job runs in the test stage.
image: node:14.14.0
artifacts:
paths:
- "test-results.xml"
reports:
junit: "test-results.xml"
stage: test
script:
- apt-get update && apt-get install -y openjdk-8-jdk
- npm i
- npm i -g firebase-tools
- firebase use $MY_PROJECT
- echo "Running unit tests..."
- npm run test:ci
When trying to install firebase-tools I get this error from the CI
$ npm i -g firebase-tools
npm WARN deprecated request#2.88.2: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated uuid#3.4.0: Please upgrade to version 7 or higher. Older versions may use Math.random() in certain circumstances, which is known to be problematic. See https://v8.dev/blog/math-random for details.
npm WARN deprecated har-validator#5.1.5: this library is no longer supported
/usr/local/bin/firebase -> /usr/local/lib/node_modules/firebase-tools/lib/bin/firebase.js
> re2#1.16.0 install /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> install-from-cache --artifact build/Release/re2.node --host-var RE2_DOWNLOAD_MIRROR || npm run rebuild
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.br ...
Writing to build/Release/re2.node ...
Trying https://github.com/uhop/node-re2/releases/download/1.16.0/linux-x64-83.gz ...
Writing to build/Release/re2.node ...
Building locally ...
npm ERR! code EACCES
npm ERR! syscall scandir
npm ERR! path /root/.npm/_logs
npm ERR! errno -13
npm ERR!
npm ERR! Your cache folder contains root-owned files, due to a bug in
npm ERR! previous versions of npm which has since been addressed.
npm ERR!
npm ERR! To permanently fix this problem, please run:
npm ERR! sudo chown -R 65534:0 "/root/.npm"
glob error [Error: EACCES: permission denied, scandir '/root/.npm/_logs'] {
errno: -13,
code: 'EACCES',
syscall: 'scandir',
path: '/root/.npm/_logs'
}
> re2#1.16.0 rebuild /usr/local/lib/node_modules/firebase-tools/node_modules/re2
> node-gyp rebuild
gyp WARN EACCES current user ("nobody") does not have permission to access the dev dir "/root/.cache/node-gyp/14.14.0"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp"
gyp WARN install got an error, rolling back install
gyp WARN install got an error, rolling back install
gyp ERR! configure error
gyp ERR! stack Error: EACCES: permission denied, mkdir '/usr/local/lib/node_modules/firebase-tools/node_modules/re2/.node-gyp'
gyp ERR! System Linux 5.4.109+
gyp ERR! command "/usr/local/bin/node" "/usr/local/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js" "rebuild"
gyp ERR! cwd /usr/local/lib/node_modules/firebase-tools/node_modules/re2
gyp ERR! node -v v14.14.0
gyp ERR! node-gyp -v v5.1.0
gyp ERR! not ok
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! re2#1.16.0 rebuild: `node-gyp rebuild`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the re2#1.16.0 rebuild script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
Any suggestions on how to fix this?
You're actually encountering an issue that isn't necessarily related to gitlab-ci, but it actually related to node 14. Essentially that /root/.npm folder has bad permissions in node 14. You have three ways you can fix this:
Update to Node 15 (just change your image to node:15) which fixes the permission issue
Allow node permissions to scan the folder. This is insinuated by the error message you have in the above error where it tells you the directory can't be scanned. The easiest way to resolve this issue is to remove the -g off the second node install, which will make it deploy to the user folder instead of global. Since you're rebuilding the container every time and using the same user each time, the -g to install globally is redundant in this case.
Install Firebase using the standalone method to get the CLI instead of using NPM to install it. You can do this in a docker container using curl -sL firebase.tools | sed 's/sudo //g' | bash
Hopefully this helps!

How to install expo cli correctly?

I am trying to install expo cli globally but I am getting errors:
OS: Catalina 10.15.4
Node: 14.6
npm ERR! code EACCES
npm ERR! syscall access
npm ERR! path /usr/local/lib/node_modules
npm ERR! errno -13
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! [Error: EACCES: permission denied, access '/usr/local/lib/node_modules'] {
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules'
npm ERR! }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
npm ERR!
npm ERR! If you believe this might be a permissions issue, please double-check the
npm ERR! permissions of the file and its containing directories, or try running
npm ERR! the command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/mac/.npm/_logs/2020-07-25T10_36_46_119Z-debug.log
I install in the Visual Studio terminal, I also tried to install through the console, but the result did not change
When installing some packages globally, you need to do so as a privileged user. On Mac, use sudo to elevate the installation command. E.g. sudo npm install your-package -g

Error when installing the express application generator

I recently installed node and express with the help of the mozilla tutorial. I am on the next step of installing the application generator, but when I run
npm install express-generator -g
in my terminal: I recieve the following errors:
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules
npm ERR! path /usr/local/lib/node_modules
npm ERR! code EACCES
npm ERR! errno -13
npm ERR! syscall access
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! stack: 'Error: EACCES: permission denied, access \'/usr/local/lib/node_modules\'',
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! Please try running this command again as root/Administrator.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/adamgusky/.npm/_logs/2018-02-17T20_26_53_688Z-debug.log
I've been googling this topic for an hour now and I am very new to using the terminal for web applications (this is for a school project), so any help is appreciated.
I had a similar issue. The problem is that you aren't an administrator so you can't write to that folder. However it's considered a BAD IDEA to run sudo npm install. So what you need to do is to change the default install folder for npm global installation to one where you do have write permission.
See npm's documentation: https://docs.npmjs.com/getting-started/fixing-npm-permissions.
And also see this useful article on github: https://github.com/nodeschool/discussions/wiki/Installing-global-node-modules-(Linux-and-Mac)