How do I get npm to run in terminal? - node.js

I'm tasked with creating a simple calculator application for entry to a programming course. I'm having issues with Terminal :(
I'm not looking for an answer to my overall task, I just want to know why Terminal wont RUN!! What am I doing wrong?
Steps as follows:
Create a directory that you will keep your Calculator application in. Call it
something sensible, like "Calculator".
Open up a command prompt and navigate to your calculator directory
Run npm init to create a new Node.js project. Use the default answer to every
question it asks you (just press "Enter") - don't worry if you don't understand
what all the questions mean!
If it doesn't do anything after the final question "Is this ok?", double-check
there's a file in the folder called package.json . If it's there, everything went
smoothly and you can exit the npm init process by typing in the console
Ctrl + C .
So my problem is... when I run npm, all that happens is my Mac asks if Terminal can access or change files in my system, I click yes, then Terminal doesn't do anything from there, no questions etc I just get:
I can't see package.json, so I take it it hasn't worked properly? How can I fix this to move on?
I'm using zsh on terminal.

Well, first off. What ide do you use? (Personally I like Visual Studio Code).
I'm not sure what the short command is for you to open up the terminal but just google it. Otherwise, you can click "Terminal" on the very top and open a new terminal.
When you do this, you will get a new window at the bottom of your screen. This window has some tabs, make sure you are in the terminal tab.
While there, type "npm init".
This will give you your package.json-file.
If you want to use your terminal for outputs I recommend you get nodejs too.

Related

Compiling pascal program in Visual Studio Code for Linux

Recently, I switched my OS to Ubuntu. I just started with collage and I have to learn pascal for my finals. But a problem occurred.
I installed Visual Studio Code and Pascal extension for it, but I am unable to run even a simple Hello World code. I wrote code, it saved automatically as .pas, but when I enter debug & run option in VSC it displays a message that says 'Open a file which can be debugged or run.', followed by 'debug' and 'run' buttons that I am unable to click and another message that says 'To further configure Debug and Run create a launch.json file.'
I am not even sure am I supposed to post questions such as this one on stackoverflow, but I sincerelly hope that someone could give me a hint on what to do. Solve this within Visual Studio Code or switch to another IDE (and which one would you recommend for Linux user) and pretend that nothing happened?
Thanks in advance.
I know this isn't an answer to "how to debug with pascal with vscode" but, perhaps you would find it easier to just use FPC / Lazarus (IDE) to do your work. While it doesn't have a dark theme, contrary to popular belief, that's not necessary to program.
The IDE is feature packed and allows for full code completion, debugging, etc... (everything you really need to do the work for school).
Additionally, you can use this open source tool to install everything you need for your platform in just a few button clicks (also allows for installing common library packages)
https://github.com/LongDirtyAnimAlf/fpcupdeluxe/releases
download release for your OS
under "FPC Version" & "Lazarus Version" select trunkgit (or stable for an older version)
click the "Install/Update FPC + Lazarus" button
Have you Installed Pascal extension which is available for code to smoothly run pascal code.
If you haven't then try installing this extension using,
Launch VS Code Quick Open (Ctrl+P), paste the following command, and press enter.
ext install alefragnani.pascal
You can always check,
https://marketplace.visualstudio.com/items?itemName=alefragnani.pascal
to install and configure pascal in vscode.
I will direct you to the debugging page from the Visual Studio Code documentation that details how to use the debugger and configure a launch.json file. VSCode is a generic IDE so you need to give it some information about your project before it knows how to run the debugger. This is what launch.json is for.
If I could make a suggestion. When you're learning how to program, it's best to start with the basics. Write a small program in a text editor (VSCode is fine, or Vim, or Nano, or Notepad, or whatever). Save the file. Compile and run the program on the command line.
Once you put an IDE in the mix, you have to learn how to use that as well. If you're stuck on both parts, it can be hard to make progress. That said, it's good to learn how to use the IDE, and you should spend some time reading the documentation and working through some of the examples. It takes some time, but it will pay you back a thousand times when you can work more quickly.

How to run Selected Text using activate.bat instead of ps1 in Visual Studio Code?

Running into this weird issue and I don't seem to be able to find a solution online or forums. My VS Code was working fine last night, but this morning when I launched VS Code and trying to execute code (in Python) using the Run Selected Text feature, I kept getting "& "C:/Users/jiejenn/Documents/Python Venv/vtest2/Scripts/activate.ps1"
& was unexpected at this time." error message.
In the past, VS Code is using the activate.bat file, which is what I want, but all of sudden, PowerShell took over the command. I am trying to revert back to using the activate.bat file instead of activate.ps1.
Can anyone provide me with some guidance how can it be done? Thanks.
I have already Googled for the past 2 hours, haven't find any solution that solves the issue.
It sounds like your default terminal application changed from cmd to PowerShell, possibly during an update. Click the terminal dropdown button and then Select Default Profile to change it back to cmd.
See also this related issue.

Trying to get customization of Sublime Text 3 Build system to work

Does anyone know how automatic build systems work in 3083 right now? Because I am struggling to get it to do the right thing. (p.s. I am not an expert st3 customizer so I am probably just doing it wrong.)
My TypeScript.sublime-build file lives in ../Packages/User and contains:
{
"cmd": ["/usr/local/bin/tsc"],
"file_regex": "^(.+?) \\((\\d+),(\\d+)\\): (.+)$",
"selector": "source.TypeScript"
}
When I edit a .ts file the syntax highlighting is for TypeScript and that is also what is displayed in the bottom right corner. So from that I deduce that ST3 is correctly identifying the desired syntax for the file (although I am not sure where that happens.)
When I choose the TypeScript build system by hand and click CMD-B it runs the build and displays the output in the console, as I expected.
When I have "automatic" build system and I open a .ts file or change to a .ts file that was already open, ST3 again correctly identifies the syntax (bottom right in the window.) However when I click CMD-B it runs the last build method that I happened to have used.
I thought that the idea with automatic is that it would choose the build system based on the syntax identified via the file extension.
Does anyone understand this problem or correct my assumptions?
Never figured out the problem. But I fully uninstalled ST3 and reinstalled it, with the package control and typescript packages and nothing more, and now it seems to work. Oh well. I guess not all the bugs are out yet.

Python IDLE GUI not starting

I feel like I have been coming the internet for days with absolutely no result.
I have taken some web programming classes, and would like to learn some python, just because programming is wicked interesting altogether, and have run into a fairly large hurdle given my experience.
the problem is this: Python.exe (or is is more properly pythonw.exe?) v3.3.3, running on windows 8.1 used to launch fine. Typed up a simple program to roll various sided die, worked out well. Then I changed the key bindings for 'Run Module' from 'ctrl+f5' to 'crtl+alt+spacebar.'
As soon as I did this IDLE crashed and so did the shell. Now the process will not run AT ALL. I cannot access it through the desktop icon to go back and revert the settings. I also attempted to look at the .def files and change it from there but could not find the 'run module' command. It looked like all the key bindings in the .def files were for the shell.
When I double click, nothing, when I run as admin, nothing. run from the start menu, nothing. I uninstalled and re-installed, rebooted, everything low tech I can think of. Now i'm out of my element and could use one of you brilliant social programmers!!
I've found information about checking with some tool called 'Windows Process Manager' some stuff about what to do with the CMD prompt (something about a path problem ...it intuitivly sounds like I very well could have created a 'path problem' but I'm not 100% I know what that is exactly).
I'm sorry for the lack of links, the pages were farther back in my browsing history than I expected. Hopefully i'm not asking an instant many down vote question here, most of the resources online are for either an older version of windows, Lunix, or an older version of python (which is actually where the path problem hint came from)
Thanks any and all greatly for any time spend reading/answering.
Immensely appreciated.
Find file HOME/.idlerc/config-keys.cfg, where on Win7 HOME would be 'C:/Users/yourloginname', and delete the key binding or, if there is nothing else in the file or nothing you want to keep, the whole file.
If you were to run Idle from a console with python -m idlelib, you would probably see an error message. (Yes, you were probably running with pythonw, as when using the start menu or icon. This works better in 3.4.2 and I am working or more improvements.)
I do not know the specific reason for your crash. I set Zoom-height to --space, restarted, and it works, no problem.

Sublime 2 text - build during saving a .js file

Please, is there an option, how to disable auto-build, when i am trying to save a .js file?
I was elaborating a node.js + express tutorial, and all the time I've saved the file, the build was starting the node.exe binary, what is something that i dont want, only solution was to tick the Build system for example for JSLint, but it still tries to build when I'm saving a file.
I know there is an tick option in Tools -> Save all on Build, but i cant find the inverse option - disable Build all on save.
I've installed the Node package for Sublime 2, and even when its disabled the build system Nodejs trys to build during the saving proces (ctrl+s)
thanks for all hints!
Here are my custom user packages:
"installed_packages":
[
"Dart",
"JavaScript Console",
"JavaScript Snippets",
"JSLint",
"Mocha Runner",
"Mocha Snippets",
"Nodejs",
"Package Control",
"Require Node.js Modules Helper",
"sublime-jslint"
],
This problem was caused by the nodejs package for sublime text 2 - after removing the package completly (not just disabling) I got an error msg when trying to save the app.js
pressed CTRL+S error: Error trying to parse build system: No data in
C:\Users\username\AppData\Roaming\Sublime Text
2\Packages\Nodejs\Nodejs.sublime-build:1:1
Problem solved, but I still don't know, why sublime was calling nodejs.sublime-build direct after saving the app.js file.
Strange behavior, maybe a bug or a unwanted feature (When a file is saved, the pre-set build system is called direct after the save)
Problem solved by removing the whole package.
If you go to the Tools menu, does the Build option have the shortcut Ctrl-S next to it? If so, your key-mapping probably got messed up at some point. Put the following line in your Key Bindings - User file (in the Preferences menu) and save it by selecting File -> Save (double check that its shortcut is still Ctrl-S as well).
{ "keys": ["ctrl+b"], "command": "build" },
Remove the , at the end if it's the last (or only) line in your user keymap.
You can go to Preferences -> Package Settings and through the menu options for each entry, looking for additional keymap definitions. Also, check Preferences -> Key Bindings (Default) and search for build to see if it got changed there to ctrl+s. If so, feel free to change it back to b.
Have you verified "save" is actually being run on ctrl+s? If not, open up the console ctrl+backtick and enter sublime.log_commands(True) Then press ctrl+s If save is being run, you should see command: save. If not, one of the plugins is grabbing the ctrl+s keybinding before it falls back to default.
If save is running, on of the plugins probably has an on_post_save or on_pre_save listener that is kicking off the build. I checked what I thought would be most likely (Mocha Runner) and it does have an on_post_save listener. I don't know if that's what you are seeing, but it would certainly explain it. Try disabling the plugins and rerunning the save to see if that is the case. If it is, you may want to create an issue on whatever plugin, asking them to make the "build on save" optional.

Resources