How to properly connect linter in Atom with jshint - javascript

I want to use the linter package in the Atom Editor. I have installed the packages "linter" and "linter-jshint". Additionally I installed jshint via npm (globally) and downloaded the jshint-repo from GitHub.
When I just try to run the linter on an open .js file in Atom, it fails with message "Error running JSHint". The same happens if I point the executablePath for linter-jshint in the Atom config to the downloaded repo folder.
When I set the executablePath to the node.js Module ("linter-jshint": executablePath: "C:/Users/Username/AppData/Roaming/npm/node_modules/jshint") it just shows a warning ("JSHint return an invalid response, check your console for more info"). Developer Tools console shows:
[Linter-JSHint] SyntaxError: Unexpected end of JSON input
at JSON.parse ()
at Object. (main.js:157)
at Generator.next ()
at step (C:\Users\Username.atom\packages\linter-jshint\lib\main.js:3)
at process._tickCallback (internal/process/next_tick.js:103)
What am I doing wrong? Do I have to point to another subdir or a specific file?
Username contains space and a german umlaut "รถ".
PS: I can execute jshint from command line and it works.

On Executable Path field, you should actually point to jshint executable file, like this:
H:\node_modules\jshint\bin\jshint

Related

How to add missing package to exe file in Javascript with pkg

I am developing a program to send messages by whatsapp through whatsapp-web.js module, I want to make my program an executable, for this I am using "pkg", however when I generate the executable, I get the following message.
Warning Cannot include directory %1 into executable.
The directory must be distributed with executable as %2.
%1: ..\node_modules\puppeteer\.local-chromium
%2: path-to-executable/puppeteer
I already copied the path where it is requested, here you can see it in vscode
However, when I run the executable I get this:
C:\snapshot\romer\node_modules\puppeteer\lib\cjs\puppeteer\node\Launcher.js:105
throw new Error(missingText);
^
Error: Could not find expected browser (chrome) locally. Run `npm install` to download the correct Chromium revision (982053).
at ChromeLauncher.launch (C:\snapshot\romer\node_modules\puppeteer\lib\cjs\puppeteer\node\Launcher.js:105:23)
at PuppeteerNode.launch (C:\snapshot\romer\node_modules\puppeteer\lib\cjs\puppeteer\node\Puppeteer.js:125:31)
at Client.initialize (C:\snapshot\romer\node_modules\whatsapp-web.js\src\Client.js:95:39)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at process.runNextTicks [as _tickCallback] (node:internal/process/task_queues:65:3)
at Function.runMain (pkg/prelude/bootstrap.js:1941:13)
at node:internal/main/run_main_module:17:47
Does anyone know how to solve this error? I have searched in forums but I have not seen anything that helps me, my code in Github: https://github.com/rromerov/Whatsapp-Web-Project/blob/main/codigo.js

Why do I get a bash: syntax error near unexpected token on every bit of code with VS Code?

I am very new to coding, and have just installed VS Code, and installed Node.js as well as Git Bash. I was working on a project, but couldn't console.log anything as I always received the following error when using Git Bash:
bash: syntax error near unexpected token `validateCred' (One of the
variables I used)
I created a new JS file, and ran the following code:
const hello = 'hello world';
I still received the same bash error. I have tried replacing my code with code that I know works and still receive the same errors.I have also tried using Powershell as my terminal, but receive the following errors every time:
batch : The term 'batch' is not recognized as the name of a cmdlet,
function, script file, or operable program. Check the spelling of the
name, or if a path was included, verify that the path is correct and
try again.
I am at a loss, and I'm sure it's something really simple, but I can't seem to figure it out!
A Bash shell expects you to enter Bash code and not JavaScript code.
If you want to run JavaScript code then you need to run it in Node.js and not in Bash.
Generally, the command node will launch Node.js in a Bash shell. (Assuming it is installed on the $PATH).

Can't run node file using Visual Studio Code terminal

I am trying to execute a file using the terminal included in Visual Studio Code. However, I cannot seem to get it working and end up receiving the following error message:
Example, "node myfile.js" --> module.js:549
throw err;
^
Error: Cannot find module c:\somepath
Is there anyone who knows what the problem might be?
Run Visual studio as Admin and also the Node package location should be accessible for your user
I had your problem before
you should run cmd as administrator.
then type : powershell set-Executionpolicy Remotesigned
and
enter.
now you can run node in vscode .

node js returning Syntax error: Unexpected identifier

I downloaded and installed node.js on Windows and I'm following a simple tutorial from nodebeginner.org.
I've created a file called HelloWorld.js which contains just:
console.log("Hello World");
When I type node HelloWorld.js in the node.js console I get:
SyntaxError: Unexpected identifier
I checked my classpath variable and it has the C:\Program Files\nodejs\ on it.
HelloWorld.js is still open in Notepad++ for editing.
What am I doing wrong?
I think you are already in the the console.
Just follow the steps to fix the error:
1) Try doing CTRL + C couple of times. See if you exit the console
2) Then do node HelloWorld.js
I think you will get your output
When in your node console already, you can simply do require("./HelloWorld.js") to get the output. (Given that you are in the directory that contains this file)
When I type node HelloWorld.js in the node.js console I get
You should type JavaScript into the Node.js console.
node is a program name. HelloWorld.js is a command line argument. They are not JavaScript.
You should type those into your shell (e.g. Windows Powershell or bash).
I had the same issue when following an online course, my mistake was that i did not safe the file i was following as .js in the name when saving.
Therefore my Hello.js did not open because it was only Hello
If people are facing below-mentioned error: Uncaught SyntaxError: Unexpected identifier at the time of running, console.log("Hello World"); code with command, node HelloWorld.js, in VS code editor
Problem :
node HelloWorld.js ^^^^^ Uncaught SyntaxError: Unexpected identifier
Solution :
(1) Just install Babel JavaScript extension in VS code editor
(2) After Babel JavaScript extension is installed, save your Program and then run your program with the command, node HelloWorld.js
Definitely will get the expected result.
I'm on linux and I'd the same issue
what I was writing in terminal is :
node
node file.js
all what I had to do is to write node file.js from the start without writing node first .
Although the question is old, I just solved it. So for anyone who still likes an answer: Apparently Node.Js installs two different consoles or executables. There is "Node.js" and there is "Node.js command prompt". Use the latter and it will work
To clarify, I used another tutorial in Dutch. Use the Javascript code in there and then in your web browser type http://localhost:3000. There you will see the Hello World output.
A little late but I figured this out as I'm learning it as well. You are not in the correct Node.js command window:
You are probably trying to run Node.js, ie. the one with the red arrow. This gives you the "Unexpected identifier" error. You want the Node.js command prompt, or the one shown with a green arrow.
Craig
On windows hit CTRL + D to exit REPL and then run HelloWorld.js again

Node.js with Webstorm -

I've followed this example to try and add a record to MongoDB database.
When trying to run ./server/server.js I get the following message (at 2:22 in video):
"C:\Program Files (x86)\JetBrains\WebStorm 9.0.1\bin\runnerw.exe" "C:\Program Files\nodejs\npm" server.js
CreateProcess failed with error 193 (no message available)
Process finished with exit code 0
The node.exe path is right but don't know why I'm getting this error and can't find information on debugging it.
I got the same error while using WebStorm with Babel as the Node executable. After re-installing the dependencies, the correct path to the babel-node executable was node_modules\.bin\babel-node.cmd.

Categories