Cannot start npm serve on MacOS, IntelliJ ultimate on vuejs project - node.js

I am failing to start npm serve at Run/Debug Configuration in IntelliJ.
But doing it separately in Terminal within IntelliJ or on plain console works.
What's going on? How to solve that?
Here's what the Run console shows:
/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run serve --scripts-prepend-node-path=auto
> pwdstorage#0.1.0 serve
> node_modules/.bin/vue-cli-service serve
env: node: No such file or directory
Process finished with exit code 127
As mentioned before running the command
/usr/local/bin/node /usr/local/lib/node_modules/npm/bin/npm-cli.js run serve --scripts-prepend-node-path=auto
on a terminal will properly work; even in IntelliJ.
At IntelliJ/Preferences.../Languages & Frameworks/Node.js and NPM the Node interpreter is set to /usr/local/bin/node and the Package manager is set to /usr/local/lib/node_modules/npm They both do exist.
What the frag is going on?
I would love to get a deeper understanding of the whole thing and do appreciate any inseide views on this.

The issue is that node is not on your $PATH; on MacOSX the environment variables differ between GUI applications and within the terminal. Terminal environment is only available to applications started from terminal.
To solve this problem, IDEA tries to load terminal environment by executing some scripts on startup, but it seems that it can't retrieve all needed stuff in your case - thus the issue. As a workaround, you can try starting IDEA from terminal.
Some links you may find useful: http://apple.stackexchange.com/questions/106355/setting-the-system-wide-path-environment-variable-in-mavericks, http://apple.stackexchange.com/questions/51677/how-to-set-path-for-finder-launched-applications.. The problem is that the way to define system-wide environment variables on Mac changes from one version to another (even minor system updates may break your environment)

As lena answered, it did help. Thank you for your help!
Starting it from the terminal does the job.
In my case I build a starter script
#! /bin/bash
/Applications/IntelliJ\ IDEA.app/Contents/MacOS/idea &
I am running the ultimate version of IntelliJ. The CE version does have another path to start!
The next two nice things to have would be
to have the opened terminal window automatically closed
link it with a proper icon placed on the desktop.
If anyone can help, go ahead!-)

Related

Npm command not found in visual studio code

Please tell me how i can solve it. Iam using window 7 32 bit:
By default, Visual Studio Code runs shell commands like npm in a loginless shell. If you installed NVM, Visual Studio Code may have no indication where to find npm to run it.
Put the following lines are in .bash_profile: (Note: Not .bashrc.)
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
Add this setting to settings.json:
"terminal.integrated.shellArgs.linux": ["-l"]
On Mac OS , I switched to the zsh and got this fixed. These following steps fixed the issue :
On your VsCode in Mac : shift + command + P .
On the Prompt > type : Terminal: Select Default Profile , then "Click it". Note, as you type you will find this option in the auto-complete .
Click the option for zsh or your desired shell.
Restart VSCode .
now npm will work in your vscode terminal.
I too had this issue.
To solve this follow the below steps.
Make sure you have npm installed
- go to command prompt & type npm -v
- if a version comes out it's installed, else go to https://nodejs.org/en/ and download same.
Then come to vs code and set deafult shell to cmd.
to do so,
- Press Ctrl+Shift+P and type Select Default Shell
- Select Command Prompt.
- Press Ctrl+`
- Type npm -v and see npm works. :)
I got this error after having just installed nodejs/npm, and the way i resolved, while still being able to use git bash terminal in vscode was to simply restart my computer (I hadn't done this after node installation).
I needed to kill the terminal in VS Code and restart a new terminal to get npm to show as installed.
As you're aware, you can configure your environment variables in windows at 2 levels.
At user level
At system level
When VS code is started, it picks the variables in path at a user level and not at system level because you haven't run the application as Administrator.
Just copy-paste your node path from System Variables to User Variables
This does the trick for windows.
Thanks.
If you just installed your node while your VScode was running. Restart your vscode it should start working.
You need to install npm first, https://www.npmjs.com/get-npm and make sure npm command is accessible using terminal/command prompt.
You can also use https://marketplace.visualstudio.com/items?itemName=eg2.vscode-npm-script This extension supports running npm scripts defined in the package.json file and validating the installed modules against the dependencies defined in the package.json.
On mac, I switched the default shell from bash to zsh and it fixed the issue.
I'm gonna add an answer just for help others because this question is 2 years old.
If you can run the npm start (NPM SCRIPTS below the Explorer view) but you are not able to launch the command with a shortcut: Then check npm extension is installed and/or enabled for the current workspace/folder.
Otherwise vsCode will not be able to run the script and you're going to get a message in a little box like this
command 'npm-script.start' not found
Maybe the NPM Scripts View below the explorer is not available without the plugin I'm not sure
For me, restarting VS code and even my PC didn't work, but after restarting VS code via "reload" (not restart, not refresh) from ctrl+shift+P, then in the top right of the terminal clicking the leftmost button and clicking "kill terminal" then restarting VS code it worked.
I had this issue too and I'm running QubesOS which uses virtualization.
I could manage to get it running until I'd a standalone VM.
That solved my problem.
Just mentioning for the ppl using virtualization like virtual box or VMware.

Node & Npm not recognized by WebStorm's terminal

I have paths to Node and NPM in both my user defined environment variable PATH and in system variable Path.
For node: C:\Program Files\nodejs
For npm: C:\Users\Username\AppData\Roaming\npm
Now node and npm are recognized by Windows Command Prompt but not by WebStorm's terminal. I get error:
'node' is not recognized as an internal or external command
Does anyone know what is problem? I could use WebStorm's terminal normally till today, but something went wrong and now I'm stuck.
EDIT:
echo %PATH% screenshot:
Settings/Tools/Terminal
screenshot:
I had similar issue. I had to select File -> Exit from the IntelliJ application as opposed to using IntelliJ's internal restart option: File -> Invalidate Caches / Restart -> Just Restart.
I had the similar problem like this.I was working with my project with another computer. and after that i decide to work with this project with my computer.so after moving the Files of project. i installed the Node.js and i had all of the paths about Node but when i was want to Run the project. i had this problem. i search a lot but nothing works. so i guess maybe when i restart my computer the new paths of variable system will work well. i restarted and my problem solved!
For those who are encountering this problem when you try to edit the run configuration, you have to put "start" as the command instead of "npm". By default Webstorm knows it's a npm project so it already starts with npm, you simply have to put the start command after that.

PhpStorm terminal npm (node)

I've just recently started using gulp.js in my projects and I've been trying to learn and use terminal a lot more.
When I run npm commands from the mac terminal default console everything works great however when I run the same commands in PhpStorm the command is not found.
I've followed PhpStorm's guides on installing and integrating the NodeJS plugin etc but I cant seem to get any of the commands to work through it even though its in my usr/local/bin and was installed globally etc.
When I SSH to vagrant though I can use the npm commands etc. Would anyone happen to be able to suggest anything?
This one is quite old but I came across the same problem.
What I did was enter the terminal settings under tools > terminal, go to Application Settings, and change the Shell path to the one you need.
Click the ... button and select the one that suits you.

Problems with Coda 2/CoffeeScript plugin

Regarding plugin for Coda 2. I am having some problems making it work. I have written a small test program in CoffeeScript, but when i try to run and/or compile I get the following error message:
All settings/env. variables should be set correctly:
Do you have any idea as to what that may cause this issue? I have installed node using homebrew, and then coffee script via npm. All the shell variables have been verified, and I am able to run node from the command line and write scripts there. Also, when i go to settings and click on "About", I get the following:
Hope you can help.
Thank you and best regards,
Thomas
In Terminal, run the command:
which coffee
For me, this gave:
/usr/local/bin/coffee
So in the CoffeeScript Plug-In Settings, I set PATH to:
/usr/local/bin
Then when I went to the About box, it showed the version of CoffeeScript that I have installed and the Run & Compile options then worked fine.

Node.js Cygwin not supported

I am trying to install node.js. I followed this tutorial and i am stuck in the middle.
When I write ./configure in my cygwin terminal it says "cygwin not supported". Please help me out
Thanks in advance.
Node in my experience runs fine in cygwin, what Node usually has EINVAL errors in seems to be MINTTY which is a terminal emulation 'skin' that is default to cygwin. I still am not sure why these EINVAL errors happen 100% but the following are the steps and tricks I use to get node working.
In my /cygwin/home/{username}/.bashrc I add node to path so cygwin can find it
export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/"
If you run a 32 bit version of node:
export PATH=$PATH:"/cygdrive/c/Program Files (x86)/nodejs/"
Then to make npm run without windows to linux issues I launch cygwin in admin mode then run:
dos2unix '/cygdrive/c/Program Files/nodejs/npm'
At this point running files and most npm packages will run in MINTTY just fine, although every once and awhile you will run into EINVAL issues with certain npm packages as karma. Also you will not be able to run the interpreter directly in MINTTY, anytime I want to do these things I run:
cygstart /bin/bash
This will open a native cygwin bash.exe window, from here you run the interpreter or an any troubling package command that results in a EINVAL. It slightly sucks you have to do this but I rarely use this day to day, and I love MINTTY too much to not use it.
Also note that you can run any one line node code in MINTTY by just running something like:
node -e "console.log('hello node')"
As a simpler derivative of troy's answer for those just looking to install NPM packages:
Install Node.js with the Windows installer package.
Add it to the PATH with export PATH=$PATH:"/cygdrive/c/Program Files/nodejs/" (obviously replacing the path to Node.js's installation directory with where you installed it).
There's a current bug in the Windows version that can be fixed by running mkdir -p ~/AppData/Roaming/npm. This is a bug for all of Windows and not just Cygwin. At some point of the future, you won't have to do this anymore, but the command shouldn't have any negative side effects.
Test it. Eg, npm install pretty-diff -g.
In order to be able to run the newly installed software, you'll need to add the install locations to your PATH. You can find these with npm bin -g and npm bin (the -g flag is the "global" installation location).
Not really anything special that you have to do to get it to run in Cygwin (although I can't say if everything works).
Use Console2, it allows you to run create tabs of CLI shells. It seems running cygwin inside console2 allows me to use node REPL just fine. I have no idea why :P
Follow this guide to add cygwin to console2:
http://blog.msbbc.co.uk/2009/11/configuring-console-2-and-bash-with.html
With Bjørn's suggestion (using Console2) and Soyuka's alias (steps here), my node.js v0.10.13 and npm v1.3.2 are now working under Babun v1.02, a Cygwin distribution.
For windows, Just run bash.exe in cmd, so that you could have a bash work around with cmd console directly, which could support ALL NODE WORKING PERFECTLY.
C:\Users\郷>bash
郷#CHIGIX ~
$ node
>
I'm using this wrapper in /usr/local/bin/node (note no extension!)
#!/bin/sh
_cmd="$(cygpath -lw -- "$1" )"
shift
"/proc/cygdrive/C/Program Files/nodejs/node.exe" "$_cmd" "$#"
This is far from perfect, as Node do not understand Cygwin directory tree, but works relatively well with relative names.
From Windows, run Cygwin.bat (instead of Cygwin Terminal) then in that run node: see and reply on this answer on this effectively-same question asked 1.5 years later.
Grab and run the node.js Windows installer.
In the Cygwin prompt type node
See if it works.

Resources