I am using Webstorm 7.0.3 to develop Node.Js. I have used Webstorm successfully for Html/Js apps, but for whatever reason, the code-coloring and error-highlighting does not exist in my Node.Js app that does for my Html/Js. For example, simple syntax errors don't highlight as desired.
You can see the difference in the two:
Html formatting:
Node Formatting:
While I know this is not a super critical thing, it makes it hard to debug as I code. Anyone know why it's different? I've searched Webstorms, but couldn't find anything.
Thanks in advance!
Most likely the node_modules folder is added to javascript libraries (WebStorm prompts you to configure a library on project opening). Javascript files in libraries have the inspections and error/syntax highlighting turned off by default. You can still enable them for particular file using the Hector icon in the lower right corner (http://www.jetbrains.com/webstorm/webhelp/changing-highlighting-level-for-the-current-file.html)
You can change your formatting this way:
var A = { foo: 'bar'
, forgotThatComma: false
}
So if you ever miss a comma, it would be obvious (see npm style guide for details).
Related
How do I disable typescript warnings and TS all together in Visual Studio Code for regular javascript files when working with sveltekit? When I create a project I say no to use of TS.
Actually, how do I disable the annoying popup with MDN Reference, warnings and what not in VSCode all together? This has been asked before, many times but I don't think there's a definite answer. Or has it? What is the problem? Why hasn't this been solved?
Change the checkJs property in jsconfig.json to false, if you're not into type checking that much..
The latest version of the SvelteKit template (the one you get when initializing a new project) has fixed many of the issue that come up for those of us using regular JavaScript. (there is now also an option to have type-checked JavaScript which gives you hints about types without the stranglehold of TypeScript). So it could be worth starting a new project and copying over your components/pages.
To disable the general "hover" behaviour of VSCode, you can set this with
"editor.hover.enabled": "false"
But this cuts a lot of functionality of VSCode, at that moment you have merely a better looking version of notepad.
SvelteKit works perfectly fine with just regular JavaScript, it was actually developed without TypeScript originally because the developers felt that progress was faster without it, but that is of course very subjective.
Well, sveltekit is a Typescript project so I'm not sure why you would want to use standard JS.
If you still consider to use JS, you have to disable the validation for javascript with
"javascript.validate.enable": false
in your editor's settings.json. But be aware that this disables all built-in syntax checking.
If you are specifically concerned about import/export errors, you could also add a jsconfig.json to your project, which includes:
{
"compilerOptions": {
"module": "es2015"
}
}
Regarding the MDN Popup. Not sure what exactly you are referencing to but have you tried to add
"editor.hover.enabled": false
to your settings.json? You could also hit Ctrl + , search for MDN and see what you can deselect.
I am new to JavaScript and wanted to set up my work environment. My problems might be basic or I look totally in the wrong direction so please advise me.
I am used to work with Sublime 3 and wanted to use it for writing JS code as well.
I spend half of a day on reserach for various autocomplete/support plugins for JavaScript but none of them seems to be working properly. Topics on subject are either outdated or misleading.
For example, none of them recognizes basic objects like:
document. or window.onload etc. (there is no autocompletion although it would be highlighted properly).
I tried:
JavaScript Enchancements and Completions - they don't work. I have read that there are some issues with running those two on Windows
Babel - doesn't have autcomplete
So in the end my question is: How do I set up Sublime and JavaScript or how can I get basic autocompletion in for JavaScript in Sublime 3?
Some suggestions
You can use JSHint
You can use Ternjs
You can use Emmet
You can use SublimeCodeIntel
You can use Zen Coding
Generate .sublime-completion file manually
Adding Snippets Custom/PackageControl/GitHub
Have you tried LSP? It works for both ST3 and ST4.
https://github.com/sublimelsp/LSP-typescript
I am new to JavaScript (coming from c++) and asking myself whether it is possible to compile and debug JavaScript code. I tried to use VisualStudio2012 and SublimeText2 with Node.js, but in both cases, I got a compile error when I tryed to use a library (3djs).
In SublimeText2 the error message is "ReferenceError: d3 is not defined".
I got that error trying to compile this d3js example: http://bl.ocks.org/mbostock/3828981
Strangely the example worked perfectly when I opened it in some browsers..
Can anyone tell me what I am doing wrong or whether it is even possible to compile or debug JavaScript code?
(Sorry, this seems to be a very beginner question but I did not find the answer searching for some hours...)
Best regards!
node.js also doesn't compile the JavaScript (not in the C++ sense; JavaScript interpreters often Just-in-Time compilation). The main difference between node.js and a browser is that node.js doesn't try to hide errors from you.
So the first question is whether you correctly included the library in your project. For this, we need to see the source code that you use to load / import it.
If you're sure that the library has loaded correctly, then you might be triggering a bug in the JavaScript interpreter. Try to install the latest version or the lastest stable version or the version before that.
[EDIT] In HTML, you use a <script> element to include scripts in the context of the page. When using node.js, then you have to use require():
var d3 = require('./d3.js')
That said, D3.js is a client framework. It expects the standard browser environment like a DOM. It will not work inside of node.js. node.js expects modules (= stuff that you can import using require) to have a certain format.
So the simple answer is: You can't "compile" and debug JavaScript code in your IDE. You always need to create a HTML page and open that in a browser. All modern browsers have consoles, plus tools to debug and examine JavaScript, CSS, HTML and the DOM.
The default javascript editor for Eclipse has very poor outlining and code completion. As a result of this, for any modern javascript application like ExtJS or NodeJS where you need to write a lot of object literal statements, Eclipse becomes pretty useless. And it is impossible to ask how to do this properly.
Now I found that Ebay Open Source seems to have tools that are specifically designed to replace this flaw in the standard editors, both for javascript in general as for NodeJS specifically.
Installing the normal NodeJS V8 debugger on a default WDT install of Eclipse is pretty straightforward, and apart from setting up some script mapping, it's easy to get to work.
But when I tried installing VJET, stuff just didn't work. No code assist at all, no debugging anymore, nothing. VJET mode was set as default for debugging and stuff, but when I couldn't get it to work, I couldn't find any option to switch back to normal Eclipse/JS Editor/V8 Debugger either. Even when I removed all VJET stuff, my Eclipse installation was bombed and a complete wipe of the workspace and home configuration + downloads finally fixed this.
So I was hoping that anyone could explain:
What are the exact steps to getting VJET to work for Node.JS development in Eclipse, and possibly how can one switch between 'VJET' mode and 'default' mode?
I've just setup Eclipse with Aptana Studio 3 and have been trying to get code completion / code hinting / autocomplete to work with mixed results.
I've followed the instructions here: http://wiki.appcelerator.org/display/tis/JavaScript+Library+Support
What I have discovered through testing is that when you install the .sdocml file and nothing else in a new project, it works fine.
As soon as I add a local copy of Dojo into the project the code hinting no longer works correctly.
I tried excluding the directory from view with a filter but that excludes it from the server so you can't use it. I've also tried removing the Dojo folder from Indexing but that changes nothing either.
If I load Dojo from a CDN, like Google, then I can use code completion.
The issue is that Eclipse picks up a parsed reference to dojo instead of the one from the sdocml file.
The problem seems, so far, to be confined to typing 'dojo.' but 'dijit.' and 'dojox.' work okay, maybe because of the parent-child relationship between those sub-libraries, if I were to guess.
I don't know if this is an Aptana bug or an Eclipse bug, but either way, it's a problem.
Does anyone know how to prioritize the code hinting sources and / or exclude certain directories from being a hinting source? Or is there another solution?
Thanks in advance,
Ken
Edit: Now that I have more code in the test project hinting does not work at all for 'dojo.' but still works fine for 'dojox.' and 'dijit.'. Only native JS methods hinting is available as a subset of 'dojo.'