calling npm from webstorm commad line tool - windows

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.

Related

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

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

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.

Node.js failed to install global npm packages on windows (not path)

So, I have a strange problem that I'm not even sure I can identify. I just installed the current version of Node.js (v.10.*) on my Windows 7 machine. I have tried to install a couple packages globally (gulp and yoeman), but I get errors when they are installing and in my C:\Users\Michael\AppData\Roaming\npm\node_modules directory, many of the package files are missing. Obviously, when I try to run the command globally, it fails because there IS NO command. It was never created.
Some other globally installed packages work fine (bower and grunt).
To make things really tricky. When I install gulp to a local folder (without the -g), the install works perfectly and I can use gulp by prepending the entire path before the command. Obviously, I could add that path to my system properties so the command would be global, but that wouldn't really fix my problem. Why does the install produce errors when installing globally, but not when installing locally?
As I watch the directory while gulp is installing locally, I see the files being created. Then the first error comes along and many of the files are deleted.
I believe the relevent parts of the log for my gulp install are:
6949 verbose lock lodash.noop#2.4.1 C:\Users\Michael\AppData\Roaming\npm-cache\7e62c2bb-lodash-noop-2-4-1.lock
6950 error Error: ENOENT, lstat 'C:\Users\Michael\AppData\Roaming\npm\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-stream\node_modules\glob2base\node_modules\lodash.findindex\node_modules\lodash.createcallback\node_modules\lodash._baseisequal\node_modules\lodash._releasearray\node_modules\lodash._arraypool'
6951 error If you need help, you may report this *entire* log,
6951 error including the npm and node versions, at:
6951 error <http://github.com/npm/npm/issues>
6952 error System Windows_NT 6.1.7601
6953 error command "C:\\Program Files\\nodejs\\\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "install" "-g" "gulp"
6954 error cwd c:\wamp\www\phoenix\animus\gulp
6955 error node -v v0.10.28
6956 error npm -v 1.4.9
6957 error path C:\Users\Michael\AppData\Roaming\npm\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-stream\node_modules\glob2base\node_modules\lodash.findindex\node_modules\lodash.createcallback\node_modules\lodash._baseisequal\node_modules\lodash._releasearray\node_modules\lodash._arraypool
6958 error fstream_path C:\Users\Michael\AppData\Roaming\npm\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-stream\node_modules\glob2base\node_modules\lodash.findindex\node_modules\lodash.createcallback\node_modules\lodash._baseisequal\node_modules\lodash._releasearray\node_modules\lodash._arraypool
6959 error fstream_unc_path \\?\C:\Users\Michael\AppData\Roaming\npm\node_modules\gulp\node_modules\vinyl-fs\node_modules\glob-stream\node_modules\glob2base\node_modules\lodash.findindex\node_modules\lodash.createcallback\node_modules\lodash._baseisequal\node_modules\lodash._releasearray\node_modules\lodash._arraypool
6960 error fstream_type Directory
6961 error fstream_class DirWriter
6962 error code ENOENT
6963 error errno 34
6964 error fstream_stack C:\Program Files\nodejs\node_modules\npm\node_modules\fstream\lib\writer.js:284:26
6964 error fstream_stack Object.oncomplete (fs.js:107:15)
6965 verbose exit [ 34, true ]
I have log files if that would help.
Thank you.
Windows can only support 260 characters as Max Path Length. I hope nodejs developers will resolve the nesting module approach. To do a workaround I simply change the global npm modules path to c: from AppData to get some characters and it resolves the issue. I know that this hack just provide you few characters but it is working for me.
To do so,
Open notepad in Administrator mode.
Go to location [nodejs installation directory]\node_modules\npm
Open file "npmrc" and change prefix=c:\npm
Save the file.

"cannot find module" when installing npm modules on windows

I am new to NodeJS. I am trying to use npm on Windows 8.
I have installed using chocolatey, cinst nodejs.install (version 0.10.17). I installed as administrator (and would prefer to run npm as a normal user).
Node itself seems to be working, I can use the REPL to run simple programs.
If I try to install something using npm, I get cannot find module:
> node npm install express
module.js:340
throw err;
^
Error: Cannot find module 'C:\Users\Klas\Documents\My Dropbox\mina egna\tech\node\webserver\npm'
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
I have read the answers on Nodejs cannot find installed module on Windows? but unfortunately it is still unclear to me what I have to do.
I have tried setting NODE_PATH:
In trying to follow this answer, I have tried setting it to C:\Users\Klas\AppData\Roaming\npm\node_modules (but I had to create both the npm and the subfolder node_modules myself)
I have tried creating a folder c:\node\node_module (according to this advice, even though the installation did not even create a c:\node folder) and setting it to that.
I have tried setting it to C:\Program Files\nodejs\node_modules\npm\node_modules (which did exist after installation)
I have also tried to create a node_modules folder below the current working directory. As I understand it that is where local npm will be installed?
None of these helped. So it seems to me that setting NODE_PATH is not the solution?
Using the -g flag makes no difference (I would prefer not to use it).
I get the same error both as normal user and as administrator (I would prefer to be a normal user).
I get the same error no matter where I execute the command, except when I do it in C:\Program Files\nodejs, where I get
basedir=`dirname "$0"`
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
Not using windows, but I'm pretty sure it's just npm install express on windows too.

Resources