How does this javascript import of kurento-utils get recognized? - javascript

On this line:
https://github.com/Kurento/kurento-tutorial-java/blob/master/kurento-player/src/main/resources/static/index.html#L24
This javascript file is imported. However, there is no file called "kurento-utils.js" in this package. So how does this work? Is this some magic of bower?
Where does that file come from and how can I get it to be accessible in my code?
When I run this code, I get:
(index):281 Uncaught ReferenceError: kurentoUtils is not defined
Thank you!

Where is no magic:
git clone https://github.com/Kurento/kurento-utils-js
cd kurento-utils-js-master
npm install
To build the browser version of the library you'll only need to exec the grunt task runner and they will be generated on the dist folder. Alternatively, if you don't have it globally installed, you can run a local copy by executing:
node_modules/.bin/grunt
(for windows i run grunt.cmd)
cd kurento-utils-js-master/dist
Here we are
copy kurento-utils.js in your resource folder

Related

Getting Node Module Error (Cannot find module)

I am learning the Automated tests by using selenium web driver + Javascript and node.js.
Everything is working fine when I ran that script.js from the Visual Studio code terminal(by using node main.js)
Problem
I want to schedule this script in the scheduler which automatically tests the login functionality. But when I try to run it from the task scheduler then it gives Error: Cannot find module
Does anybody know how to get rid of this.
To fix Cannot find module errors, install the modules properly by running a npm install command in the appropriate directory as your project's app. ... or delete the node_modules folder and package-lock. json file and re-install it again using the npm install command.
rm -rf node_modules package-lock.json

'vue' is not recognized as an internal or external command

everything was installed correctly. but whenever I try to create project, it says "'vue' is not recognized as an internal or external command". I installed and re-installed but didn't work. npm was also added to environmental variable path.
C:\Users\touha\Desktop>npm list -g --depth=0
C:\Users\touha\.npm-packages
`-- #vue/cli#3.8.2
C:\Users\touha\Desktop>vue ui
'vue' is not recognized as an internal or external command,
operable program or batch file.
C:\Users\touha\Desktop>
Locate vue.cmd and add its location to your PATH
It is added to package manager(npm or yarn) installation. So you may find it at following locations
YARN
C:\Users{YourAccount}\AppData\Local\Yarn\bin
NPM
C:\Users{YourAccount}\AppData\Roaming\npm
just open PowerShell and run: npm install -g #vue/cli
Addition: If setting the path variable and reinstalling #vue/cli does not work, using the node.js command prompt instead might solve the issue.
It seems vue isn't been installed globally for some reasons.
This is the step I followed to solve mine:
Firstly, create your desired project folder (say "Vue Project"). This is where you want to create a vue project.
Then create a "node_modules" folder in the Vue Project folder
Then go to your system npm folder C:\Users{YourAccount}\AppData\Roaming\npm
You will see three different "vue" files. Copy them and paste in the Vue Project Folder you created.
Go back to C:\Users{YourAccount}\AppData\Roaming\npm and enter the node_modules folder. You'll see a "#vue" folder. Copy this, and paste it in the node_modules folder you created in the Vue Project Folder.
You can now head back to the CLI and create your project using "vue create my-vue-project" where my-vue-project is your desired vue project name.
You can try this way it worked for me
go to the location of your yarn or npm mine is C:\Users\TED\AppData\Local\Yarn\bin for Yarn
C:\Users\TED\AppData\Local\Npm\bin for Npm users
TED will be replaced by your user name
then copy and add it to your system environment variable
Note in case you don't find AppData make sure you have view hidden file checked
I am using Yarn to install #vue/cli.
The way I solve it is via the following steps
Locate your global installed vue.cmd location
Add the vue.cmd directory into System variable Env. For myself, the path is C:\Users{MyAccount}\AppData\Local\Yarn\.bin
what worked for me:
In a powershell :
npm install vue
npm install -g #vue/cli
C:\Users\{USER}\AppData\Roaming\npm\vue.cmd create {NAME}
if you got this error most probably chance package not installed completely
check-in C:\Users\dev\AppData\Roaming\npm
if you had not found the package under this folder then re-run your command
Run command prompt as administrator
Run setx /M path "%path%;%appdata%\npm
Restart the command prompt
Now create the Vue project

.js Files Transpiled From .ts Files Don't Run In Browser

I'm trying to use the h264-converter npm package (https://www.npmjs.com/package/h264-converter).
It is written in TypeScript. When I run npm install --save h264-converter I get a folder with the .ts TypeScript files, but it also comes with the .js Javascript files in the same folder already transpiled for you.
However, the .js files it comes with do not run in a browser. They contain Require(...) functions and undefined objects like exports that cause them not to run in a browser. Simply including these .js files with <script> tags causes errors. I did some reading and tried to use the browserify npm package (https://www.npmjs.com/package/browserify) to create .js files that work in a browser from .js files that don't. I ran
browserify "C:\...\h264-converter\dist\index.js" > "C:\...\h264-converter\dist\bundle.js"
like the in the example on the browserfiy main page and it seemed to run without error (their example uses main.js instead of index.js but I think index.js serves the same purpose). It created bundle.js. However, bundle.js still doesn't run in a broswer. bundle.js still has Require(...) functions.
How do I get the .js files that come with h264-converter npm package to run in a browser?
I can post the contents of some of the .js files that the h264-converter npm package comes with if that will help. Thanks.
npm package
To use an npm (node style commonjs) package in the browser you should use a a module bundler like webpack.

UglifyJS could not be run in intellij when configuring as a file watcher

I'm trying to configure UglifyJS file watcher in IntelliJ as stated in this link:
minifying-javacripts
But when I try to modify a javascript file and save it, I get this error:
CreateProcess error=193, %1 is not a valid Win32 application
I've installed uglify-js with the command below:
npm install uglify-js -g
And I can minify 'js' files both from windows command line and IntelliJ's internal terminal windows. But can not configure it as a file watcher properly.
I noticed that 'uglifyjs' file in the 'bin' directory of the 'uglify-js' node module, has no suffix. Then i tried to add a '.bat' suffix to it myself hoping the file watcher could run it, but it didn't work.
try to find cmd version of uglifyjs command in this folder:
node_modules.bin\uglifyjs.cmd
and set in File Watcher/Watcher Settings/Programs
Note that install the package global may not work because Intellij may not have authorization to access User/AppData/

Can't find Typescript compiler: Command "tsc" is not valid

Just installed Typescript extension to VS2012 and followed Install TypeScript for Visual Studio 2012 and then the tutorial to call the compiler:
> tsc greeter.ts
But when i try to compile .ts file where should i type: tsc greeter.ts? Tried it in VS command line and in windows console, always get the message that tsc is not recognized as command(Command "tsc" is not valid.).
If you're using tsc as a node module, make sure you've installed it with
npm install -g typescript
Then it should be available globally in your node command prompt
Ensure you have,
C:\Program Files (x86)\Microsoft SDKs\TypeScript\0.8.0.0
or,
C:\Program Files\Microsoft SDKs\TypeScript\0.8.0.0
on your path. If not, try restarting CMD.EXE and see if shows up with a fresh copy. If that fails, try adding one of the above manually to your path.
For folks on Windows with Visual Studio Code, who don't want to install full Visual Studio just for tsc.exe, I can suggest to simply download it from here: https://www.microsoft.com/en-us/download/details.aspx?id=48593.
This is a shame that this link is missing from the TypeScript download page.
Although the installer is called TypeScript for Visual Studio 2015, it works with Visual Studio Code as well.
After you downloaded and installed TypeScript, you should manually add its installation directory (C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.0\ in my case) to the %PATH% environment variable.
Open environment variables editor:
Win + S; e, n, v, i, r, o; click Edit environment variables for your account.
In the window opened find Path user variable (note that it is not named %PATH% here, but still this is it). You probably have some path set there already. You just have to type ;, append the TypeScript install location and add one more ; in the end.
Screenshot for your reference:
After this is done, open Command Prompt and type in tsc -v. If tsc.exe's version is getting displayed, you're done. For this to work, restart Command Prompt and VS Code after making the change to the %PATH%.
P.S. If you get "error TS5057: Cannot find a tsconfig.json file at the specified directory: '.'", just create tsconfig.json file in the document root (that's probably where your .ts files are) with simple contents: {}. This means "an empty JSON file <...>. This will be sufficient for most people." (source).
Usually closing and reopen the command prompt solves the issues.
Check both of these folders to find out what TypeScript version you have:
C:\Program Files (x86)\Microsoft SDKs\TypeScript\
C:\Program Files\Microsoft SDKs\TypeScript\
Right-click the folder showing the version number then 'copy as path'.
Paste this into your system path (quick access - Windows key then type 'env'). Then open a new command prompt console as administrator and 'tsc' should work.
If you have installed typescript for a specific folder/project i.e. not globally,then you can should use tsc command with npx
e.g
npx tsc myfile.ts
npx is used to excute a package .
As new path variable, don't use the displayed tsc version number but the TypeScript Folder Name which is different.
Sample :
tsc -v display 2.4.1
but TypeScript directory is
C:\Program Files (x86)\Microsoft SDKs\TypeScript\2.4
Just delete AppData\Roaming\npm\tsc.ps1 file and the issue will be fixed.
In my case, I did install typescript globally by using -g flag but tsc was not recognized.
It turns out that below directory was not included in path environment variable:
C:\Users\Jitendra\AppData\Roaming\npm
Adding this directory to path variable worked for me.
In CMD type where tsc if it doesn't show a path like this C:\Program Files (x86)\Microsoft SDKs\TypeScript\typescript version you installed\ it means your tsc is not running from here.You need to change the environment path manually by following #TranslucentCloud 's answer .
You should add the following path
C:\Users\<user>\AppData\Roaming\npm
to the PATH variable. Notice that you should change the to your windows user.
This will work like a charm. Cheers!!
Try
npx tsc greeter.ts
I was getting the same error until i tried this.

Categories

Resources