How to fix EACCES: permission denied, open '/Users/.... when installing gatsby-cli - terminal

I'm setting up Gatsby and get stuck at the beginning.
When i write npx/npm install global gatsby-cli in the terminal -
Alems-MacBook-Pro:~ alemkahrobek$ npm install -g gatsby-cli i see this:
/usr/local/bin/gatsby -> /usr/local/lib/node_modules/gatsby-cli/lib/index.js
gatsby-telemetry#1.0.4 postinstall /usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry
node src/postinstall.js
gatsby-cli#2.5.4
added 225 packages from 131 contributors in 13.617s.
If i check the version of gatsby i get this:
Alems-MacBook-Pro:~ alemkahrobek$ gatsby -v
/usr/local/lib/node_modules/gatsby-cli/node_modules/configstore/index.js:49
throw error;
^
Error: EACCES: permission denied, open '/Users/alemkahrobek/.config/gatsby/config.json'
You don't have access to this file.
at Object.openSync (fs.js:439:3)
at Object.readFileSync (fs.js:344:35)
at Configstore.get all [as all] (/usr/local/lib/node_modules/gatsby-cli/node_modules/configstore/index.js:31:25)
at new Configstore (/usr/local/lib/node_modules/gatsby-cli/node_modules/configstore/index.js:25:48)
at new Store (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/store.js:28:51)
at new EventStorage (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/event-storage.js:24:50)
at new AnalyticsTracker (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/telemetry.js:32:50)
at Object.<anonymous> (/usr/local/lib/node_modules/gatsby-cli/node_modules/gatsby-telemetry/lib/index.js:7:18)
at Module._compile (internal/modules/cjs/loader.js:689:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:700:10).
Now if i try to make a new project like:
gatsby new example
i get this:
Alems-MacBook-Pro:~ alemkahrobek$ npm gatsby new example
Usage: npm <command>
where <command> is one of:
access, adduser, audit, bin, bugs, c, cache, ci, cit,
clean-install, clean-install-test, completion, config,
create, ddp, dedupe, deprecate, dist-tag, docs, doctor,
edit, explore, get, help, help-search, hook, i, init,
install, install-ci-test, install-test, it, link, list, ln,
login, logout, ls, org, outdated, owner, pack, ping, prefix,
profile, prune, publish, rb, rebuild, repo, restart, root,
run, run-script, s, se, search, set, shrinkwrap, star,
stars, start, stop, t, team, test, token, tst, un,
uninstall, unpublish, unstar, up, update, v, version, view,
whoami
npm <command> -h quick help on <command>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/alemkahrobek/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#6.9.0 /usr/local/lib/node_modules/npm
Alems-MacBook-Pro:~ alemkahrobek$ npm help config
NPM-CONFIG(1) NPM-CONFIG(1)
NAME
npm-config - Manage the npm configuration files
SYNOPSIS
npm config set <key> <value> [-g|--global]
npm config get <key>
npm config delete <key>
npm config list [-l] [--json]
npm config edit
npm get <key>
npm set <key> <value> [-g|--global]
aliases: c
DESCRIPTION
npm gets its config settings from the command line, environment vari-
ables, npmrc files, and in some cases, the package.json file.
See npm help 5 npmrc for more information about the npmrc files.
See npm help 7 npm-config for a more thorough discussion of the mechanisms involved.
The npm config command can be used to update and edit the contents of
the user and global npmrc files.
Sub-commands
Config supports the following sub-commands:
set
npm config set key value
Sets the config key to the value.
If value is omitted, then it sets it to "true".
get
npm config get key
Echo the config value to stdout.
list
npm config list
Show all the config settings. Use -l to also show defaults. Use --json
to show the settings in json format.
delete
npm config delete key
Deletes the key from all configuration files.
edit
npm config edit
Opens the config file in an editor. Use the --global flag to edit the
global config.
SEE ALSO
o npm help 5 folders
o npm help 7 config
o npm help 5 package.json
o npm help 5 npmrc

For Ubuntu users who experience the same problem, I've solved it giving the right permissions on the specified folder:
chown -R $USER:$USER /home/$USER/.config/gatsby

Check out the official page on npmjs.com: https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I would definitely the first option on that page. nvm is pretty awesome: https://github.com/creationix/nvm

Related

Running the 'Getting-Started' Fabric Composer gets error with composer archive create; missing required options

Sequence of steps was
npm install -g composer-cli
Clone the getting started repository, and issue npm install
Lots of NPM errors are output, but some of the key ones are.
> composer archive create -m digitalproperty-network --archiveFile digitalPropertyNetwork.bna && composer network deploy --archiveFile digitalPropertyNetwork.bna --enrollId WebAppAdmin --enrollSecret DJY27pEnl16d && composer network list -n digitalproperty-network --enrollId WebAppAdmin --enrollSecret DJY27pEnl16d
composer archive create --archiveFile digitialPropertyNetwork.zip --sourceType module --sourceName digitalproperty-network
Options:
--help Show help [boolean]
-v, --version Show version number [boolean]
--archiveFile, -a Business network archive file name. Default is based on the Identifier of the BusinessNetwork [string]
--sourceType, -t The type of the input containg the files used to create the archive [ module | dir ] [required]
--sourceName, -n The Location to create the archive from e.g. NPM module directory or Name of the npm module to use [required]
Missing required arguments: sourceType, sourceName
npm ERR! Linux 4.8.0-39-generic
npm ERR! argv "/home/matthew/.nvm/versions/node/v6.10.0/bin/node" "/home/matthew/.nvm/versions/node/v6.10.0/bin/npm" "run" "deployNetwork"
npm ERR! node v6.10.0
npm ERR! npm v4.3.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! getting-started#1.0.0 deployNetwork: `composer archive create -m digitalproperty-network --archiveFile digitalPropertyNetwork.bna && composer network deploy --archiveFile digitalPropertyNetwork.bna --enrollId WebAppAdmin --enrollSecret DJY27pEnl16d && composer network list -n digitalproperty-network --enrollId WebAppAdmin --enrollSecret DJY27pEnl16d`
npm ERR! Exit status 1
The machine is clean, with no caches. Some of the other sample networks are also failing with the same error?
When the npm install -g composer-cli was issued, it installed a version of the command line tools that was at v0.4.5 or later. composer --version outputs for example.
$ composer --version
composer-cli v0.4.5
composer-admin v0.4.5
composer-client v0.4.5
composer-common v0.4.5
composer-runtime-hlf v0.4.5
composer-connector-hlf v0.4.5
The composer archive create command needs to form up the Business Network Archive from the model files, transaction files etc. It can do this in two ways
by taking a source directory
by taking a module name
The new syntax of the command is
composer archive create --archiveFile digitialPropertyNetwork.zip --sourceType module --sourceName digitalproperty-network
Options:
--help Show help [boolean]
-v, --version Show version number [boolean]
--archiveFile, -a Business network archive file name. Default is based on the Identifier of the BusinessNetwork [string]
--sourceType, -t The type of the input containg the files used to create the archive [ module | dir ] [required]
--sourceName, -n The Location to create the archive from e.g. NPM module directory or Name of the npm module to use [required]
Previously there was a --moduleName and a --inputDir name.
Examples:
To create a business network archive from the current working directory previously would have used the --inputDir . the new command is:
composer archive create --sourceType dir --sourceName . --archiveFile digitialPropertyNetwork.bna
To create a business network archive by indicating the NPM Module containing the business network would have used the --moduleName digitalproperty-network the new command is:
composer archive create --sourceType module --sourceName digitialproperty-network --archiveFile digitialPropertyNetwork.bna
In both cases above the --archiveFile digitialPropertyNetwork.bna is optional. A default filename will be created from the name of the Business Network if needed.
Why?
The inputDir and moduleName options were mutually exclusive and the internal code design was not proving resilient to handling error cases. The new approach to the options simplifies (and increases the resilience of the code).
Depending on the development approach, the artifacts that make up the business network may be created in different ways. By moving to this new style of options means we aren't precluding any other 'sourceType'. In the previous model, we would have had to add more and more command line options.

Why i cant run npm in ruby console, but in node console works good?

i need to run npm in ruby console to run grunt with compass, but when i typing npm in ruby console says "npm is not a command" but when i typing in node console works good. some help? thanks!
[I] need to run npm in ruby console
The #system method, "Executes command… in a subshell.", see: http://ruby-doc.org/core-2.2.0/Kernel.html#method-i-system
$ irb
irb(main):001:0> system('npm')
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
help, help-search, i, init, install, install-test, it, link,
list, ln, logout, ls, outdated, owner, pack, ping, prefix,
prune, publish, rb, rebuild, repo, restart, root, run,
run-script, s, se, search, set, shrinkwrap, star, stars,
start, stop, t, tag, team, test, tst, un, uninstall,
unpublish, unstar, up, update, v, version, view, whoami
npm <cmd> -h quick help on <cmd>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/dev/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#3.8.9 /usr/local/lib/node_modules/npm
=> false
irb(main):002:0>
Alternatively, backticks (`cmd`) return "the standard output of running cmd in a subshell.", see: http://ruby-doc.org/core-2.2.0/Kernel.html#method-i-60
$ irb
irb(main):001:0> puts `npm`
Usage: npm <command>
where <command> is one of:
access, adduser, bin, bugs, c, cache, completion, config,
ddp, dedupe, deprecate, dist-tag, docs, edit, explore, get,
help, help-search, i, init, install, install-test, it, link,
list, ln, logout, ls, outdated, owner, pack, ping, prefix,
prune, publish, rb, rebuild, repo, restart, root, run,
run-script, s, se, search, set, shrinkwrap, star, stars,
start, stop, t, tag, team, test, tst, un, uninstall,
unpublish, unstar, up, update, v, version, view, whoami
npm <cmd> -h quick help on <cmd>
npm -l display full usage info
npm help <term> search for help on <term>
npm help npm involved overview
Specify configs in the ini-formatted file:
/Users/dev/.npmrc
or on the command line via: npm <command> --key value
Config info can be viewed via: npm help config
npm#3.8.9 /usr/local/lib/node_modules/npm
=> nil
irb(main):002:0>

Use bower to install bootstrap 4

I'm trying to get into using my terminal on a mac. I installed npm sucessfully and when I type npm --version it gives me 2.14.12. With npm I installed bower and I think it worked. But I have two questions:
when I type bower -v it gives me this:
/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:56
throw err;
^
Error: EACCES: permission denied, open '/Users/philip/.config/configstore/bower- github.yml'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:549:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:397:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:16:32)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
but when I type sudo bower -vit works and gives me 1.7.2 after I typed in my password. Why doesn't it work without sudo?
I wanted to install bootstrap 4 in a folder on my desktop so with cd I went to the directory and typed bower install bootstrap#v4.0.0-alpha.2 and it gives me this:
/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:56
throw err;
^
Error: EACCES: permission denied, open '/Users/philip/.config/configstore/bower-github.yml'
You don't have access to this file.
at Error (native)
at Object.fs.openSync (evalmachine.<anonymous>:549:18)
at Object.fs.readFileSync (evalmachine.<anonymous>:397:15)
at Object.create.all.get (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:34:29)
at Object.Configstore (/usr/local/lib/node_modules/bower/node_modules/configstore/index.js:27:44)
at readCachedConfig (/usr/local/lib/node_modules/bower/lib/config.js:19:23)
at defaultConfig (/usr/local/lib/node_modules/bower/lib/config.js:11:12)
at Object.<anonymous> (/usr/local/lib/node_modules/bower/lib/index.js:16:32)
at Module._compile (module.js:435:26)
at Object.Module._extensions..js (module.js:442:10)
Can somebody tell me why? Thanks!
EDIT:
I'm that far now:
Philips-MacBook-Pro:test philip$ bower install bootstrap
bower bootstrap#* not-cached git://github.com/twbs/bootstrap.git#*
bower bootstrap#* resolve git://github.com/twbs/bootstrap.git#*
bower bootstrap#* ECMDERR Failed to execute "git ls-remote --tags --heads git://github.com/twbs/bootstrap.git", exit code of #69 Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
Additional error details:
Agreeing to the Xcode/iOS license requires admin privileges, please re-run as root via sudo.
The reason you are getting the EACCESS error is without sudo is because you do not have permission to access those files.
To check the current permissions of a file/directory run:
ls -l <file or directory name>
at the terminal prompt.
You will see output similar to this:
drwxr--r-- 1 owner group...
for each listing.
The first character of that ouput represents the file type. In the example 'd' means the file listed is a directory. The second group of three characters describes the read ('r' in the example), write ('w') and execute ('x') permissions for the owner of the file.
The next three characters describe permissions for the group the file belongs to. In the example, you see 'r--'. This means the group that the file belongs to only has permission to read the file- no permission to write to (as indicated by the '-') or execute the file.
The final three characters describe the permissions for 'all users'. In the example, 'r--' indicates that all users have read-only access to the file.
This resource will help you understand *nix/OS X file permissions: http://www.comentum.com/unix-osx-permissions.html
In order to run those commands without sudo you will change the current permission settings to allow yourself read/write access to the files that are throwing EACCESS errors. This can be done through the GUI or with the chmod command at the terminal.
Running man chmod at the terminal brings up the man page (https://developer.apple.com/library/mac/documentation/Darwin/Reference/ManPages/man1/chmod.1.html) for the chmod command.

NPM has stopped working on Windows 7 64bit, hangs on install/update

At some point my version of NPM stopped working. It seems to have happened when I tried to update npm (from 1.4 shipping with node to a modern 2.x version) a few weeks ago and has steadily gotten worse. I had to change the Environment variable to point to my npm directory before my node directory (to pick up the new version of npm), at that point everything just stopped working. I switched the environment variable back, and then updates would just hang. But strangely when I tried to debug it and add a --verbose to the command the update would work most of the time. Sometimes they hung on the
npm http GET https://registry.npmjs.org/PACKAGE_NAME
but most of the time they worked. This now happens with the old version of NPM (1.4.1) and the new version that I installed (2.1.17), everything always fails on a GET command (usually but not always the first one). I have hit cache-clear, I have wiped out the temp directory, I have tried wiping out %APPDATA/roaming/npm/, and reinstalling everything. I have no proxy in place, but I have run:
npm config set proxy
to set the proxy to blank. I have set the registry to http (rather than https) and set strict-ssl to false. I have uninstalled and reinstalled nodejs, to no luck. I have tried running the commands from an admin cmd prompt rather than a normal command prompt all to no avail. I've run out of ideas, and really need NPM to work...
Below is the output of trying to install grunt-cli after clearing out the %APPDATA/roaming/npm directory:
C:\Users\Kris Erickson>npm install -g grunt-cli --verbose
npm info it worked if it ends with ok
npm verb cli [ 'C:\\Program Files\\nodejs\\\\node.exe',
npm verb cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
npm verb cli 'install',
npm verb cli '-g',
npm verb cli 'grunt-cli',
npm verb cli '--verbose' ]
npm info using npm#1.4.28
npm info using node#v0.10.35
npm verb node symlink C:\Program Files\nodejs\\node.exe
npm verb cache add [ 'grunt-cli', null ]
npm verb cache add name=undefined spec="grunt-cli" args=["grunt-cli",null]
npm verb parsed url { protocol: null,
npm verb parsed url slashes: null,
npm verb parsed url auth: null,
npm verb parsed url host: null,
npm verb parsed url port: null,
npm verb parsed url hostname: null,
npm verb parsed url hash: null,
npm verb parsed url search: null,
npm verb parsed url query: null,
npm verb parsed url pathname: 'grunt-cli',
npm verb parsed url path: 'grunt-cli',
npm verb parsed url href: 'grunt-cli' }
npm verb lock grunt-cli C:\Users\Kris Erickson\AppData\Roaming\npm-cache\671ef8ac-grunt-cli.lock
npm verb addNamed [ 'grunt-cli', '' ]
npm verb addNamed [ null, '*' ]
npm verb lock grunt-cli# C:\Users\Kris Erickson\AppData\Roaming\npm-cache\d63f3d0b-grunt-cli.lock
npm verb request where is /grunt-cli
npm verb request registry https://registry.npmjs.org/
npm verb request id dc44ca4b260df8c3
npm verb url raw /grunt-cli
npm verb url resolving [ 'https://registry.npmjs.org/', './grunt-cli' ]
npm verb url resolved https://registry.npmjs.org/grunt-cli
npm verb request where is https://registry.npmjs.org/grunt-cli
npm info trying registry request attempt 1 at 13:36:28
npm http GET https://registry.npmjs.org/grunt-cli
/
Note: the spinner never stops (at least I have left it 10 minutes and nothing happened).
It looks like you may have installed a new npm but it is not actually being used (or did you revert back to 1.4.28?)
In either case, try following the directions here https://github.com/npm/npm/wiki/Troubleshooting#upgrading-on-windows for updating to the latest npm on Windows. Latest is currently 2.4.1. I recommend using Option 3.
Then try running your npm install command with maximum verbosity:
npm -ddd install -g grunt-cli
and upload your logfile as a gist https://gist.github.com either here or as a new issue at https://github.com/npm/npm/issues, and we'll help you get this sorted out.
The version number you're using doesn't comply with the semantic versionning convention npm uses: you need to specify a MAJOR.MINOR.PATCH version number.
You can either:
Use the 0.2.x notation to specify that you don't care what patch version you use, as long as the major.minor matches
Use the ~0.2.0 notation to specify that you don't care what patch version you use, as long as the major.minor matches
Read npm's documentation and semver's documentation for other possibilities...
Hope This helps.
I am running node in windows 8.1. This issue popped up on a new machine build and I searched for hours for a resolution with no success. Finally. in desperation I used fiddler in an attempt to see what calls were being made by npm AND magically the problems went away.
On further investigation I found that npm appears to require two windows environment variables to be set:
Try the following in a command prompt before running npm (Note: if you are actually behind a proxy then replace the empty quotes with your proxy address):
Setx http_proxy ""
Setx https_proxy ""

calling npm from webstorm commad line tool

Im just starting with grunt in webstorm (on windows) and can't call npm (node plugin is installed and enabled, node.exe is in the system path).
npm init
what command line tool outputs:
module.js:340
throw err;
^
Error: Cannot find module 'C:\nodejs\node_modules\npm\bin\node_modules\npm\bin\npm-cli.js'
at Function.Module._resolveFilename (module.js:338:15)
at Function.Module._load (module.js:280:25)
at Function.Module.runMain (module.js:497:10)
at startup (node.js:119:16)
at node.js:901:3
Process finished with exit code 8
Thanks
configure NPM with command line in Webstorm:
Webstorm 6 , you need to add command line support plugin :
File > Setting > IDE Settings > Plugins > Command Line Tool Support
once you added to webstorm then
File > Settings > Project Settings > Command Line Tool Support
click '+' to add >
in popup window
Tool Path : C:\Program Files\nodejs\npm.cmd
Alias: npm (or whatever you like)
visibility: select whatever you like
then > OK >
Apply > OK
in webstorm > Tools > Run Command > or (Coomand Line Tools Console)
type command in bottom bar: npm
you will see result something like
C:\Program Files\nodejs\npm.cmd
Usage: npm
where is one of:
add-user, adduser, apihelp, author, bin, bugs, c, cache,
completion, config, ddp, dedupe, deprecate, docs, edit,
explore, faq, find, find-dupes, get, help, help-search,
home, i, info, init, install, isntall, issues, la, link,
list, ll, ln, login, ls, outdated, owner, pack, prefix,
prune, publish, r, rb, rebuild, remove, repo, restart, rm,
root, run-script, s, se, search, set, show, shrinkwrap,
star, stars, start, stop, submodule, tag, test, tst, un,
uninstall, unlink, unpublish, unstar, up, update, version,
view, whoami
npm -h quick help on
npm -l display full usage info
npm faq commonly asked questions
npm help search for help on
npm help npm involved overview
Specify configs in the ini-formatted file:
C:\Users\kpatel.npmrc
or on the command line via: npm --key value
Config info can be viewed via: npm help config
npm#1.3.8 C:\Program Files\nodejs\node_modules\npm
Process finished with exit code 0 at 14:32:10.
Execution time: 794 ms.

Resources