The term '' is not recognized as the name of a cmdlet - javascript

When I try to check netlify is install or not then show me this error:
: The term '' is not recognized as the name of a cmdlet, function, script file, or operable program. Check the spelling of the name, or if a path
was included, verify that the path is correct and try again.
At C:\Users\alami\AppData\Roaming\npm\netlify.ps1:1 char:1
+ ...
+ ~
+ CategoryInfo : ObjectNotFound: (:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
After successfully install npm i -g netlify-cli then I get this error
I have tried to fixed this problem
Any suggestion please

Related

Js code isn't working it exits with code=1

It says that it can't find prompt-sync and exits with code=1
const prompt = require('prompt-sync')();
var fname = prompt("Enter your first name : ");
var lname = prompt("Enter your last name : ");
console.log("Your full name is : ",fname + " " + lname);
I tried to changeing
console.log("Your full name is : ",fname,lname);
to
console.log("Your full name is : ",fname + " " + lname);
You can replicate the error with just this:
const prompt = require('prompt-sync')();
This means that the problem occurs when trying to find "prompt-sync".
The documentation of prompt-sync is not ideal
I've had a quick look at https://www.npmjs.com/package/prompt-sync
It mentions the optional installation of a history module, but does not mention the main installation. This may be why it is not working for you.
How to fix
On the system command line (Windows terminal or Mac terminal), with the working directory set to the directory of your project, type:
npm install prompt-sync
If that command gives an error, first install npm itself.
Once prompt-sync is installed, you should be able to run your code.

youtube-dl showing Error: Command failed with exit code 1

I have created node js function for download youtube videos.
when I run the function following error is showing:
youtube-dl showing Error: Command failed with exit code 1: \node_modules\youtube-dl\bin\youtube-dl.exe --dump-json --format=18 --encoding utf8 http://www.youtube.com/watch?v=4FDud9Lj5HY
const video = youtubedl(
url,
// Optional arguments passed to youtube-dl.
['--format=18'],
// Additional options can be given for calling `child_process.execFile()`.
{ cwd: __dirname }
);
video.on('info', function (info) {
const _data = {
thumbnail: info.thumbnails[info.thumbnails.length - 1].url,
size: info.size / 1024 / 1024
};
});
I found a solution. I uninstall "youtube-dl" and reinstalled it. This issue is related to a plugin update
Update
Since the youtube-dl binary is updated regularly, you can run npm run update to check for and download any updates for it. You can also require youtube-dl/lib/downloader in your app if you'd like to place youtube-dl binary in a specific directory and control when it gets updates.

Ionic 3 Prod Build With Version Number

I use the following command when building an ionic project for desktop
ionic cordova build browser --prod
Which results in the following file being generated
build/main.js
However I would like to be able to add a version number to the generated file automatically as part of the build process. So would end up with something like
build/main.js?version=1.00
as to avoid needing to clear the browser cache after every prod build.
Is there a flag for this, or is it something I must do manually?
Any advice would be great!
EDIT:
My solution is on GitHub for anyone interested!
https://github.com/RichardM99/ionic-3-version-build-file-hook
Here's some advice - You can create a cordova hook.
Hooks are scripts that you want to be executed at different stages of the build process. In your case, you are looking at a script which renames the main.js file after the build event is finished, or in other words a 'after_build' type hook.
The script will usually be a Node.js file, although you can have other types of scripts executed as well.
One more thing. Since you want to get around cache, you wont be renaming the file itself. What you will want to do is rather replace the reference to "main.js" in you "index.html" to include a random or maybe your actual version number.
I have pointed you in a direction, but won't spoonfeed. Look up documentation on cordova hooks. They are super simple if you understand Javascript/Node
Something like this should get the job done:
var index_orig = fs.readFileSync(path-to-index.html, 'utf8');
var index_new = index_orig.replace("main.js", "main.js?version="+version_num);
fs.writeFileSync(path-to-index.html, index_new, 'utf8');
If you want the actual build number, you can read your config.xml and parse it to get it's value.
Hope it helps.
I wrote blog long time ago
In my build pipeline i have command to set version
version "$(app.versionPrefix)$(Build.BuildNumber)"
$(app.versionPrefix) - is a prefix version such as 0.1.
$(Build.BuildNumber) - is build version
Then I have environment file
export const environment = {
apiUrl: 'https://....',
production: true,
version: '0.0.57'
}
Then i have js script to update version in environment and config.xml
var replace = require('replace-in-file');
var package = require("./package.json");
var buildVersion = package.version;
const options = {
files: ['config.xml'],
from: /" version="([0-9]*.[0-9]*.[0-9]*)"/g,
to: "\" version=\""+ buildVersion + "\"",
allowEmptyPaths: false,
};
const optionsEnv = {
files: ['src/environments/environment.prod.ts'],
from: /version: '(.*)'/g,
to: "version: '"+ buildVersion + "' ",
allowEmptyPaths: false,
};
try {
let changedFiles = replace.sync(options);
if (changedFiles == 0) {
throw "Please make sure that file '" + options.files + "' has \"version: ''\"";
}
changedFiles = replace.sync(optionsEnv);
if (changedFiles == 0) {
throw "Please make sure that file '" + optionsEnv.files + "' has \"version: ''\"";
}
console.log('Build version set: "' + options.to + '"');
}
catch (error) {
console.error('Error occurred:', error);
throw error
}
NOTE: you need to install plugin replace-in-file
Then in build pipe line I am running this script
node ./replace.build.js
In your case if you need only for browser you can tune script.

JS String not behaving as expected

I am creating file paths like so:
'/Users/User/Documents/dev/engineerappcopy/VGimages/'+deviceName+'.png'
these file paths are passed to a function as parameters, this function uses the file path to perform a command on the terminal.
However, this string seems to split into 2 parts when used by the function. presenting this error:
exec error: Error: Command failed: /bin/sh -c adb pull /sdcard/nexLogin.png /Users/User/Documents/dev/engineerappcopy/VGimages/josh
.png
/bin/sh: line 1: .png: command not found
this is because '.png' has been separated from the main string.
Remove the new line character from the end of the deviceName variable. You should probably use the trim method to do this.
'/Users/User/Documents/dev/engineerappcopy/VGimages/'
+ deviceName.trim()
+ '.png'

jsreport doesn't render text

I have the following code , the result is a pdf which doesn't have any visible text in it. (I guess it renders it as the same color of the background even thoguh we change its colour in the inline style of the html)
var client = require("jsreport-client")('https://localhost:443');
var output = '<html><body><h1 style="color:blue;margin-left:30px;">This is a heading.</h1></body></html>';
client.render({
template: { content: output }
}, function(err, pdfResp) {
pdfResp.pipe(res);
});
When we copy and paste the content of the pdf into a text pad , the result is :
ihsish issi aa gheadinhadinge
Any idea how to solve it ?
I would guess phantomjs is missing some dependencies (fonts) required for rendering pdf. It runs for me if I spin up fresh centos VM on azure but I see people complaining sometimes required phantomjs dependencies are not preinstalled. Adding the missing package depends on your distribution
For example on ubuntu you may need to run:
sudo apt-get install build-essential chrpath git-core libssl-dev libfontconfig1-dev
on centos
sudo yum install freetype fontconfig

Categories

Resources