Reputation: 3
I am using Sublime Text 3 and whenever I build it with my build system for JavaScript. It gives me an error. Code below as well as error:
function makeid(length) {
let result = '';
const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789';
const charactersLength = characters.length;
let counter = 0;
while (counter < length) {
result += characters.charAt(Math.floor(Math.random() * charactersLength));
counter += 1;
}
return result;
}
console.log(makeid(5));
And then the error:
[WinError 2] The system cannot find the file specified
[cmd: ['/System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc', 'C:\\Users\\me\\Documents\\Projects\\Password Generator\\script.js']]
[dir: C:\Users\me\Documents\Projects\Password Generator]
[path: C:\Program Files (x86)\Common Files\Oracle\Java\javapath;C:\Program Files\National Instruments\Shared\OpenVINO\;C:\Program Files (x86)\Intel\iCLS Client\;C:\Program Files\Intel\iCLS Client\;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files\Intel\Intel(R) Management Engine Components\DAL;C:\Program Files (x86)\Intel\Intel(R) Management Engine Components\IPT;C:\Program Files\Intel\Intel(R) Management Engine Components\IPT;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Git\cmd;C:\Users\me\AppData\Local\Microsoft\WindowsApps]
[Finished]
I tried running the code and it didn't work and I'm expecting it to generate me a random string.
Upvotes: 0
Views: 48
Reputation: 41
To generate a JavaScript string in Sublime Text editor, you can follow these steps:
Open Sublime Text editor and create a new file by selecting "File" > "New File" from the menu or by pressing "Ctrl+N" on Windows or "Cmd+N" on Mac.
Type the following code to create a string variable and assign a value to it: var myString = "Hello, world!";
Save the file by selecting "File" > "Save" from the menu or by pressing "Ctrl+S" on Windows or "Cmd+S" on Mac.
Choose a location and name for the file and save it with a .js extension, for example "myFile.js".
To test the code, you can open a new browser window and create a script tag to reference the file,
Finally, open the HTML file in a web browser and check the console output to see the string value printed:
Upvotes: -2
Reputation: 169338
Your "build system for JavaScript" expects you to have a /System/Library/Frameworks/JavaScriptCore.framework/Versions/A/Resources/jsc
binary - that's an obviously macOS path, and you're evidently running on Windows.
You'll want e.g. node.js if you want to run console JavaScript on Windows, and then fix your build system to use node instead.
Upvotes: 0