I got a problem when I input any node cmd, - node.js

I got a problem when I input any npm cmd, it says
internal/modules/cjs/loader.js:584
Operating System: Windows 8 pro 64bit
What shall I do to solve this issue?

Your error message of:
Error: Cannot find module 'C:\Users\NUMAN ALI\myfirst.js'
indicates that Node can't find your myfirst.js file to run within your current directory of: C:\Users\NUMAN ALI. Your myfirst.js file isn't located within this directory so you need to move into the correct directory containing this file, or alternatively create this file in the current directory. Then you need to add your desired JavaScript within this file to run it.
With your comment of: "The file you have just created must be initiated by Node.js before any action can take place" I am going to assume you don't have this file in your current directory. Maybe you could try creating the file in a text editor, such as notepad at the very least on a Windows machine, and adding the JavaScript contents into this file. Then try re-running the file with a node myfirst.js. Check out this accepted answer here as I think this will help you out a lot. Also, for command line help for creating files, check out this link.
Hopefully that helps!

Related

Pumba installation - Command not found on linux terminal

I am trying to install pumba from the OS release page. Once it is downloaded, I try running
pumba --help
It gives a command not found error.
Can anyone suggest what am I missing? The amd_64 file has all read, write and execute permissions.
If the name of the file is pumba_linux_amd64, you have to use that. Additionally, since the file is (assuming) not in your $PATH, you can't launch it directly.
If your file is in your current directory, run
./pumba_linux_amd64

Possible way to create a command line tool in node.js

I am building a nodejs based small framework for my application. Say, the name of the framework is coffee-cup, situated in the folder of the same name. The folder has a structure inside. To simplify the work of developers, I want to add few command line methods. For example, consider following folder structure.
coffee-cup
|--config
|--cups
|--cup1
|--index.js
|--report
|--cup-config
|--cup2
|--index.js
|--report
|--cup-config
We see that inside cup1 and cup2, there is same structure. If a developer wants to add a new cup called cup3, they will need to create a folder called cup3 and add the underlying structure into that folder.
To automate this task, I am thinking of a way to build a command line utility like
$ coffee-cup new cup cup3
that can work on linux, windows or mac terminals.
Expected result of Entering this command in terminal: would create a new folder called cup3 in cups folder and will create the file index.js and folders reporting and cup-config inside the folder cup3.
I can create folder using fs.mkdirSync()and file using fs.writeFile().
I am however, unable to find a way to make the terminal identify the coffee-cup command. If terminal identifies this command, it should collect the following arguments and pass on to the nodejs file and I can continue from there. What I know is, that there exist npm packages like inquire which are useful in creating command line applications. But it does not help in building command line utilities like I mentioned above.
So I am looking for guidance on making terminal identify the coffee-cup command, collect the following arguments and pass on everything to a nodejs file. It is just like we install npm and then terminal starts identifying the npm keyword and subsequent commands like $ npm install. Any help by experts will be highly appreciated.

sublimeREPL - "can't open file '$file_basename'"

When I try to execute more than an operation using SublimeREPL and Python3 I get :
C:/Users/Name/Anaconda3/envs/keras/python.exe: can't open file '$file_basename': [Errno 2] No such file or directory.
Following this answer I have modified the sublime-settings file adding "default_extend_env": {"PATH": "{PATH};C:/Users/Simone/Anaconda3/envs/keras"}.
I have also add the path C:/Users/Name/Anaconda3/envs/keras/python.exe in Main.sublime-menu file, but I'm still getting the same error message.
You do not have to modify you sublime-setttings file. I suppose that you have your subl configured to run with python3 but it doesn't matter.
When you use ctrl + b for running your code, you must be sure that you have something written. Is only that, if you use ctrl + b but you don't have anything in your code file is normal that you were obtaining that error.
When your cursor not in the current python file [may be in output panel of the SublimeREPL or may be in empty tab/file] and if you are running
Tools->SublimeREPL->python->python - RUN currentfile
then you may get below error. Because there is no file's path for that output panel file or for an empty file.
C:/Users/Name/Anaconda3/envs/keras/python.exe: can't open file
'$file_basename': [Errno 2] No such file or directory
So, focus your cursor in the current python file and try it again.
This may be one of the case.I faced this problem and after few trials i figured it out.
did you save the file?
I have had the same problem. I saved the file and it worked

Node.Js windows command prompt change C:\ path to test directory instead

I'm trying to figure out if there is a way to change the Node.Js command prompt default path = C:\users...> (default when the prompt is launched) or C:\Windows\System (if launched with administrator privileges), to the location of the folder where i'm working.
Normally I have been doing C:\users..> cd C:\xampp\htdocs..... to navigate to the test folder and run test. Although once the command prompt is closed it reverts back to C:\users...>.
To achieve what I want I came across using Z:>C:\xampp\htdocs\projects.... but this returns access denied with or without administrator privileges. Even if I try C:>C:\xampp\htdocs\projects.... still get the Access Denied for some unknown reason. To be honest I don't know what Z:> or C:> will result.
Is it possible to change the default prompt path to the path of the directory I am working in so that every time command prompt is launched it goes to that directory? In this case C:\xampp\htdocs\projects.... instead of C:\users...>
This seems like a general windows CMD question. Simply change the start up directory for CMD. See this SO post.
Once you're in that directory, you should be able to run the node command as normal.
Look inside your default nodejs installation folder for a file called nodevars.bat. Here is my path:
C:\Program Files\nodejs\nodevars.bat
Open this and look towards the bottom--the line I needed was on the very bottom. Here is the line from the git master:
if "%CD%\"=="%~dp0" cd /d "%HOMEDRIVE%%HOMEPATH%"
I changed mine to
if "%CD%\"=="%~dp0" cd /d "C:\Users\David\Desktop\work\J\math"
And now I am happier.
I had the same question, today, 4/11/22, and DuckDuckGo provided this as the number one result for my query. Since the question appears to be unanswered, I will try for those who might show up later.

julia: system image file "sys.ji" not found

I am using the IDE Netbeans to code a project c++ under Linux(red hat 7). As I need to use some math functions, I try to embed the julia language into my c++ project.
Here is what I have done:
Download the Julia from here (I choose this: Generic Linux binaries)
Set project properties: build-->C++ Complier-->Include Directories, add the include of Julia, something like this: ../myjulia/include/julia
Add the libraries: open a terminal and type the command line: sudo ln -s ../myjulia/lib/julia/libjulia.so /usr/lib/libjulia.so
Now if I run my project, I will get this error: System image file "../myproject/dist/Debug/GNU-Linux-x86/../lib/julia/sys.ji" not found
I hve checked this file: ../myjulia/lib/julia, in this file, there are all of the lib files (libjulia.so etc) and a file named "sys.ji".
I ran into this issue after installing Julia v0.3.10 on a Windows machine and thought I'd post it in case it can help someone else.
When I ran julia.exe it gave me the error message listed above.
Problem:
I had created a system environment variable called JULIA_HOME and pointed it to the directory where Julia was installed. Then, I added %JULIA_HOME%\bin to my PATH.
Solution:
I pointed JULIA_HOME to the \bin directory under the Julia install directory. Then, I added %JULIA_HOME% to my PATH
A "hello world" example from here
Now we know that we need to setup the julia context with this code:
jl_init(NULL);
In fact this code may not setup a good context because the project can't find the system image file "sys.ji". So what we need to do is using another function instead of jl_init: jl_init_with_image. This function accept two parameters: the first is the path of the image file, the second is the name of the image file. So we should use it like this: jl_init_with_image("/thePathOfSys.ji", "sys.ji"); One more thing: the path of sys.ji must be the absolute path.

Resources