I don't know what I changed but Intellij is not detecting the npm scripts anymore. I was creating a second tsconfig file and after that it stoped working. I created a new project and cleared the cache but IntelliJ keep saying that there is no script
Please make sure that *.json pattern is assigned to either JSON or JSON5 file type in Preferences | Editor | File types
Related
I'm building a .Net Core application using Angular for my client-side code. For the most part, I'm using the default template that is included in VS 2017. For whatever reason, VS is making my node_modules folder read only. Before I was able to install packages via command line in the directory that holds my client side code as well as my package.json file and my node_modules folder. Before I was able to do this, but now it is defaulting the folder to read only which is invaliding all of my npm commands. I've verified that this is the case because I can remove the read only attribute via windows explorer and then run any of my commands like npm install.
Has anyone else encountered this before? If so, what did you do to resolve this?
Thanks!
Okay, I found the answer. VS puts a lock on the node_modules folder while it is running.
So, I guess for now if you need to add packages just close VS first.
Always feel stupid asking here because people are always confused with my questions, or I have a dumb problem, but, I'm working on a program in node.js and the text editor I'm using (NP++) doesn't seem to like to save files in the system32 directoy, (The directory where my modules are), and that is where my script is as well. (So I have .../.../node_modules/(modules) and .../.../node_modules/script.js) this becomes a pain when I want to edit the script, I have to clone the script to my desktop, then edit it, then overwrite the one in the node_modules directory. I tried saving the script to my desktop and running it, but it just gives me an error of module not found. (In my script I have the modules as var example = require('example.js')) Is there any way I can get it to get the modules from the node_modules directory, while keeping the script file somewhere easily accessible and editable? (i.e desktop?) (Sorry if this is confusing, not the best at these kind of things)
I'm not 100% sure that this is what's happening because I haven't used npm on Windows, but it sounds to me like you're installing your dependencies globally using npm -g. The more proper way to use Node is to install your dependencies locally, using npm without the -g flag. That way your dependencies get installed in your current working directory.
For example, let's say you've saved your project in a directory on your Desktop, and your script uses require("lodash"). If you cd to your directory and run npm install lodash, then the lodash module will be available to your script.
I try to build and debug an extension in Code.
I downloaded the sample of word-count from https://github.com/microsoft/vscode-wordcount.
When I clicked F5, ./out folder was not generated and I saw failure: Activating extension ms-vscode.wordcount failed: Cannot find module 'd:/VSCode/vscode-wordcount/out/extension'.
I found the post
https://github.com/Microsoft/vscode-go/issues/35
and I think this was because I failed to build the extension.
And I checked my path that node and npm were both set.
I found there were 2 possible issues.
I could not find .\node_modules folder in my extension folder. The folder structure is like
.vscode\
-- launch.json
-- settings.json
-- tasks.json
image\
test\
typings\
-- vscode-typings.d.ts
extension.ts
package.json
tsconfig.json
My node version is v0.12.2.
Could you give me some hints how to investigate the issue?
You probably downloaded directly from GitHub.
You will need to run npm install in your project's folder in order to create the node_modules directory and add the required dependencies.
If you simply want to install the extension to use it, you will also need to:
Move the folder to the correct place
npm install
OR
Install the built version directly from the Visual Studio Marketplace through the command pallet.
I'm testing the new code editor from Microsoft : Visual Studio Code.
I'm under Windows 7 and i'm trying this example : https://code.visualstudio.com/Docs/nodejs
But when i try to add /// <reference path="/typings/node/node.d.ts"/>
like it is said in the example. It does'nt work. The file is never downloaded and i don't know where i can find it.
Is someone knows how to fix that ? Is it a bug or the problem come from my machine ?
TSD is TypeScript Definition, while TypeScript is a typed superset of JavaScript from Microsoft that compiles to plain JavaScript. You don't need to understand these if you just want to use VSCode to develop common JavaScript-based node.js projects like me.
To solve your problem, I think a better way is to install the TSD package manager as a global module. This will enable you to use the command tsd globally.
npm install tsd#next -g
Then go to the root folder of your project, and type
tsd install node
This will automatically create a folder 'typings/node' with a .ts file named 'node.d'.
If you also need IntelliSense for third party modules like express.js or async.js, you can just add them by yourself
tsd install express
Just like 'npm' which you already be familiar with is the package manager for node.js, 'tsd' is the package manager for TypeScript Definition (but not for TypeScript itself)
There's a list here showing the available repositories.
http://definitelytyped.org/tsd/
Once you download all the .tsd files into the 'typings' folder, you still have to manually put these special comments at the beginning of each .js files to help VSCode look up the definitions for node and express, so now VSCode knows the API details of the classes and functions.
/// <reference path="typings/node/node.d.ts"/>
/// <reference path="typings/express/express.d.ts"/>
I just tried last night and it worked fine.
You shouldn't put the reference by yourself. You should let VS Code do it for you by pressing "Ctrl + ." (thats the dot key you should press) on the marked __dirname and choosing the option for the TypeScript Definition file as said on the website.
VS Code will create the directories structure under your project folder, download the file and add the reference to your app.js express application.
I had the same problem with angular and this is how I got it to work for me: It looks like the problem was that VSCode failed to download the file and create the directories. I googled angular.d.ts and found it on GitHub - DefinitelyTyped
I created "typings/angularj/" folders and added the file and now intellisense is working for angular :)
So just grab the "node.d.ts" file instead of from DefinitelyTyped and it should work for you as well.
As #HenryLi mentioned, you need to get a file with type definitions for Node. However TSD has been deprecated for quite a while now. Worry not, however! Now the type definitions are managed directly by Microsoft and bundled right through npm!
To solve your problem, it's enough to run this command:
npm install --save -g #types/node
(Edit: VS Code needs me to open a directory, and not a single file to let intellisense work well)
Same problem for me.
This does not work:
Add /// reference to 'node/node.d.ts'
Nothing happens...
But this does work, VS Code is responding. (Edit: stops the warning, but no auto-completion this way):
Mark '__dirname' as global
I am using VIM as my text editor and Yeoman to help me with my webapp development workflow.
I am already using vim-jshint to help me lint my javascript files from within VIM and I would like to use it in sync with my Yeoman setup.
My problem is that every time I run grunt, the jshint task founds lots of errors that vim-jshint couldn't find.
I am aware vim-jshint looks for a .jshintrc file in two possible paths: the HOME path and the current working directory but, in its current state of development, vim-jshint seems to be unable to find the .jshintrc that Yeoman uses, which is located in the base directory of the webapp.
Has any of you found a solution or workaround for this?
Please, switching to Sublime Text is not an option.
Got it! I was using the wrong vim-jshint plugin.
I should have used the one that's listed in JSHint's site from the beginning, but somehow I was misled to the wrong plugins. Stupid me.
Finally, having pathogen.vim installed, I just had to copy and paste this:
cd ~/.vim/bundle
git clone git://github.com/walm/jshint.vim
As stated in its own github README file, This plugin is a front for the jshint NodeJS cli module which ensures that running :JSHint inside VIM will always report the same errors as grunt's jshint task. At least if you run VIM from the same folder where JSHint's options file (.jshintrc) is located.