/bin/sh: node: command not found - in VScode, running Javascript - javascript

Im trying to run this simple code in VSCode for learning Javascript but I keep getting this error:
[Running] node "/var/folders/xr/30nkhmxs7159fblbjtfj2jhw0000gn/T/tempCodeRunnerFile.javascript"
/bin/sh: node: command not found
[Done] exited with code=127 in 0.014 seconds
I've looked online and have tried changing the CodeRunner Executable Map as I saw in another post but it doesn't seem to be helping.
Thanks!
let admin, name; // can declare two variables at once
name = "John";
admin = name;
alert( admin ); // "John"

First of all, check the output of which node in the default terminal application. If the output is empty, this means that the path where the node binary resides is not in your $PATH.
Try to find the location of the node executable. After this, check what's the shell you're using by running echo $SHELL. If it returns something like /bin/bash, create a file(may already exist) named ".bash_profile" or ".bashrc" and there, add the following: export PATH=$PATH:<location of node>, replacing <location of node> with the actual location of the node binary.

in this page: How to run javascript code in Visual studio code? /bin/sh: 1: node: not found
dmcquiggin had resolve this problem:
Locate the path to your Node executable, by typing the following command in a terminal:
which node
The result will be similar to the following (I use nvm to manage my Node versions, yours might look a little different)
/home/my_username/.nvm/versions/node/v10.15.1/bin/node
Make a note of / copy this path.
Open VS Code. Either press Ctrl+, (on Linux), or from the File menu, select Preferences > Settings.
In the search box at the top of this window, type:
Executor Map
Click the 'Edit in settings.json' link displayed under the first result.
Add the following to the end of the settings file, replacing the path with the one from step 1.
"code-runner.executorMap": {
"javascript": "/home/my_username/.nvm/versions/node/v10.15.1/bin/node"
}
this also works on my mac, cheers

Related

Build input file cannot be found: '/Users/wt/myfolder/Todo/ios/QRCodeFrameProcessor/QRCodeFrameProcessor.swift'

At first my Project running fine. when I add this command according to
the library of react-native-vision-camera it adds some files in IOS
folder. I run this command npx vision-camera-plugin-builder iOS
and it add some folder of frame processor. after that it gives some
error whenever I run the code. after that I delete all the folders of
QRFrameProcessing which was created . now I received another error
SwiftCompile normal x86_64 Compiling\ QRCodeFrameProcessor.swift /Users/wt/myprojects/todo/ios/QRCodeFrameProcessor/QRCodeFrameProcessor.swift (in target 'todo' from project 'todo')
/Users/wt/myprojects/todo/ios/ios/QRCodeFrameProcessor/QRCodeFrameProcessor.swift:1:2: error: #objc attribute used without importing module 'Foundation'
#objc(QRCodeFrameProcessorPlugin)
I just need to know that how to delete all the frame Processors which I have added from the above command I mentioned
this is the link where I add frame processor for IOS
you can check the Frame Processor manual setup instructions and revert these changes. For example for SWIFT version is like this:
Remove QRCodeFrameProcessorPlugin.swift
Remove generated BrigingHeaders files
Remove QRCodeFrameProcessorPlugin.m
https://mrousavy.com/react-native-vision-camera/docs/guides/frame-processors-plugins-ios/#manual-setup

Convert the ssd_mobilenet_v1_coco model with tensorflow_js

I want to build an app with javascript which integrates object-detection. For this, I wanna use the ssd_mobilenet_v1_coco model and use it in tensorflow.
However this line of code:
C:\Users\Jonas\AppData\Roaming\Python\Python36\Scripts\tensorflowjs_converter --input_format=tf_saved_model --output_node_names='image_tensor, detection_boxes, detection_scores, detection_classes, num_detections' \saved_model\saved_model \saved_model\web_model
does not work. It gives me file not found error, but the file is actually there unless I'm very dump and turned back into computer beginner.
OSError: SavedModel file does not exist at: \saved_model\saved_model
Also, I'm not quite sure about the output node names but this is secondary.
Thanks for support, hopefully I'm not totally dump :)
This might be because you are using an absolute path instead of a relative path.
On mac or linux, if you are in the directory that contains the downloaded unzipped model, you would run a command of that type :
tensorflowjs_converter --input_format=tf_saved_model --output_node_names='detection_boxes,detection_classes,detection_scores,num_detections' --saved_model_tags=serve ./ssd_mobilenet_v1_coco/saved_model ./ssd_mobilenet_v1_coco/web_model
From what i can see you are on Windows.
If you are running your command from the directory that contains the saved_model folder, you should run the following command :
C:\Users\Jonas\AppData\Roaming\Python\Python36\Scripts\tensorflowjs_converter --input_format=tf_saved_model --output_node_names='image_tensor, detection_boxes, detection_scores, detection_classes, num_detections' .\saved_model\saved_model .\saved_model\web_model

Node.js/ v8: How to make my own snapshot to accelerate startup

I have a node.js (v0.6.12) application that starts by evaluating a Javascript file, startup.js. It takes a long time to evaluate startup.js, and I'd like to 'bake it in' to a custom build of Node if possible.
The v8 source directory distributed with Node, node/deps/v8/src, contains a SconScript that can almost be used to do this. On line 302, we have
LIBRARY_FILES = '''
runtime.js
v8natives.js
array.js
string.js
uri.js
math.js
messages.js
apinatives.js
date.js
regexp.js
json.js
liveedit-debugger.js
mirror-debugger.js
debug-debugger.js
'''.split()
Those javascript files are present in the same directory. Something in the build process apparently evaluates them, takes a snapshot of state, and saves it as a byte string in node/out/Release/obj/release/snapshot.cc (on Mac OS). This file seems to be baked into Node.
Some customization of the startup snapshot is possible by altering the SconScript. For example, I can change the definition of the builtin Date.toString by altering date.js. I can even add new global variables by adding startup.js to the list of library files, with contents global.test = 1.
However, I can't put just any javascript code in startup.js. If it contains Date.toString = 1;, an error results even though the code is valid at the node repl:
Build failed: -> task failed (err #2):
{task: libv8.a SConstruct -> libv8.a}
make: *** [program] Error 1
And it obviously can't make use of code that depends on libraries Node adds to v8. global.underscore = require('underscore'); causes the same error.
I'd ideally like a tool, customSnapshot, where customSnapshot startup.js evaluates startup.js with Node and then dumps a snapshot to a file, snapshot.cc, which I can put into the Node source directory. I can then build node and tell it not to rebuild the snapshot.
I just added an option to the mksnapshot command (which runs while you are building V8). The new --extra-file=filename.js flag lets you specify a file that is to be loaded and run in the process and then put in the snapshot. It's on the trunk version of V8, not the 3.11 branch that is being used for node 0.8 so you will have to run node 0.8 with V8 version 3.11. As far as I know at the moment that works, but you will be somewhat on your own.
Please file bugs if you try this and it doesn't work for you.

doctorjs(aka jsctags) not work with vim+tagbar

I am using windows 7 64bit...
I've installed nodejs 0.6.11 by MSI installer, the installation path is "C:\Program Files (x86)\nodejs", it was automatically added to my %PATH% by the installer, I installed doctorjs by steps below:
I copied doctorjs files under "C:\Program Files (x86)\nodejs\doctorjs"
I created jsctags.cmd filled with content copied from https://gist.github.com/1438882
I added following lines in my _vimrc:
let g:tagbar_type_javascript = {
\ 'ctagsbin' : 'C:\Program Files (x86)\nodejs\jsctags.cmd'
\ }
The problem is, when I run jsctags.cmd "{My js folder}", it generates tags file with only content below:
!_TAG_FILE_FORMAT 2 /extended format/
!_TAG_FILE_SORTED 0 /0=unsorted, 1=sorted, 2=foldcase/
!_TAG_PROGRAM_AUTHOR Patrick Walton /pwalton#mozilla.com/
!_TAG_PROGRAM_NAME jsctags //
!_TAG_PROGRAM_URL http://github.com/pcwalton/jsctags /GitHub repository/
!_TAG_PROGRAM_VERSION 0.1 //
And when I run :tagbaropen in vim, it shows nothing for current js file..
Please kindly guide me where I did wrong, thank you!
Since you're getting some output, it looks like you have the gist implemented correctly. But maybe your expectation of how to use it at a command line is different than the way it really works?
FYI: jsctags.cmd "{my js folder}" returns an empty tags file on my machine too. I don't think the command interface is very mature yet... so it looks like creating a tagfile of a whole folder is not possible - yet...
Try jsctags.cmd "{file}". This should create a populated tag file.
Also note that tagbar calls jsctags like this: jsctags -f - {file}. This streams the output to stdout. So if you're debugging, try this form of the command.
As another debugging tip, modify your batchfile to output debugging info. ie:
Add lines like this:
echo "%~dp0"\"node.exe" "D:\opt\node\doctorjs\bin\jsctags.js" %* > d:\debug.txt
Looking in d:\debug.txt will let you see what the command looks like as it is called from tagbar.
BTW: The gist you're using was mine... I am wondering if I didn't test this batch file well enough with folders that have spaces in them. Do some tests in both folders with and without spaces to see if there is a difference. If you get more insight into where it works/doesn't, let me know and I can investigate further.
Your issue might be related to the commit of narcissus you've cloned for doctorjs. Go into the narcissus folder in the doctorjs folder and run
git checkout 4ae5aff8b3
This should switch the head to the proper version of the file.

Where to place JS files for NodeJS to see them

I've just installed NodeJS on my Mac, and i got it working in the terminal, using inline scripting like "console.log('Hello world'); works fine.
But where do i place JS files for NodeJS to find them? Can i specify the root folder NodeJS to look for file in?
I followed this guide: http://nodeguide.com/beginner.html#learning-javascript
but i cannot get any of the samlpe to work where i reference a script file.
You put them in whatever folder you want. It is common practice to put each application in a different folder.
Then you run node.js like this:
node /path/to/file.js
Or like this:
cd /path/to/
node file.js
Where file.js might look something like this:
console.log('hello world');
You'll have to navigate to the correct folder "manually", in the Node Command Line Interface (CLI).
If you need to change drives, type the drive letter and a colon to switch to that drive, like so;
C:> (<- this is the line prompt, yeah? Just add this after it -> D:
That changes the drive. Now write cd (CD = "Change Directory") and the name of the direcotry you want to go to the directory your stuff is in:
D:> (<- the new prompt. Write something like this after it: ->) cd myprosject\subfoldername
D:\myproject\subfoldername> (<- your new line prompt - if "myproject\subfoldername" exists)
now ask node to execute your script (that is stored in myproject\subfoldername, like so;
D:\myproject\subfoldername> node helloworld.js
Remember to write "node" first - otherwise the command won't go to node, but to the OS, which will probably just open up the js file in a text editior instead of running the goodies inside.
It is very easy.. Go to your command line. navigate to the file location..
then simply run the node helloworld.
I'm not sure I understand. it doesnt 'look' anywhere for your .js files you point at them when you run node. Like so, on the command line:
node mynodeapp.js
If you're meaning where does it look for your .js files as modules, when requirign them, like so:
var mymodule = require("mymodule");
Then it will look inside a folder names node_modules. But I'm sure you're looking for my first example above.

Categories

Resources