Posts

Showing posts with the label Npm

Couldn't Install Npm On Ubuntu

Answer : This looks like you probably installed the chris-lea node.js ppa which is fine. However, you don't install npm from that ppa as it breaks the way debian packages work. Instead, just install nodejs . Once that's installed, run npm -v you should see it's now installed. If you didn't use the chris-lea ppa update your question on what webpage you Googled to find out how to install nodejs on Ubuntu. Try installing NodeJs like this: sudo apt-get install nodejs Since NodeJs installs node and npm Apt doesn't handle dependancy conflicts well, use snap or aptitude; sudo aptitude install npm I had to press "no" to the first solution it proposed, which did not include installing npm (that must be a bug in aptitude) then the second solution I pressed yes to hTHen check npm was installed: npm --version

Cannot Find Module 'glob'

Answer : There's already an issue reporting this error message. The workaround until the next release is to install glob for the project ( npm install --save glob ) Regarding the commands, according to their repository under Generating and serving an Angular2 project via a development server the commands are as follow ng new ponyracer : This command will create a project named ponyracer (a folder named ponyracer with all the set up in it). ng serve : This command will run the live reload server to serve the application so you can see it in your browser. PS : If you test the solution suggested in the issue it would be nice of you to report if it worked or not. PS2 : I tested now (I fixed my error) and I cannot reproduce your error. I'm using node v5.5.0 and npm v3.7.3. Can you specify which node and npm versions are you using? I had the same error on Windows 10, D:\Code\AngularJS>ng new greetings-ac Cannot find module 'glob' Error: Cannot find m...

Add Image In Header Using Html-pdf Node Module

Image
Answer : It is possible to add the image in options header. 1.Load the image in html body with "display:none" style. 2.Then add the image in the options header By doing this the image is cached and can attach the image in header. var options = { "format": 'Letter', "orientation": "portrait", "header": { "contents": "<img src='image path' />", "height": "30mm" }, "footer": { "contents": footer } } pdf.create("<div style='display:none'><img src='image path' /></div>", options).toFile("sample.pdf", function(err, res) { if (err) { console.error(err); callback(); } }); Refering to this issue on the github, you can't put your image directly in options.header , you have to put it in the body inside a <div id=...

Can I Run Two Ongoing Npm Commands In 1 Terminal

Answer : You could run one process in the background with & (one ampersand, not two) but that would require you to manage it manually, which would be rather tedious. For details see What does ampersand mean at the end of a shell script line?. For that use-case someone built concurrently , which makes it simple to run processes in parallel and keep track of their output. npm install --save-dev concurrently And your start script becomes: "start": "concurrently 'npm run webpack' 'npm run server'" If you want to make the output a little prettier you can give the processes names with -n and colours with -c , for example: "start": "concurrently -n 'webpack,server' -c 'bgBlue.bold,bgGreen.bold' 'npm run webpack' 'npm run server'"

Angular 4 CLI Too Slow After Ng Serve And When Updating

Answer : i solved my problem. What happened is that our components and other resources are all imported in app.module.ts . Because of this, the page loads all the resources every time the page loads. My solution was to apply Lazy Loading to load only those resources that are specific to the routes that i am accessing and it did fix up the loading issue. You have this problem is because your dev PC have not enough memory to handle the build as nodejs is consuming a lot of memory when you run expensive npm tasks. And the bigger your project the more memory is required to complete the task. The problem can get even worse if you want to run ng serve + ng t + ng whatewer at the same time. Check the Task manager -> Perfomrmance tab then run ng serve and you will see what I am talking about. I had struggled by the same problem until I put another 8gb RAM in my dev PC. So yes it is normal.

Convert XML To JSON With NodeJS

Answer : I've used xml-js - npm to get the desired result. First of all I've installed xml-js via npm install xml-js Then used the below code to get the output in json format var convert = require('xml-js'); var xml = require('fs').readFileSync('./testscenario.xml', 'utf8'); var result = convert.xml2json(xml, {compact: true, spaces: 4}); console.log(result); You can use xml2json npm for converting your xml in to json. xml2json. Step 1:- Install package in you project npm install xml2json Step 2:- You can use that package and convert your xml to json let xmlParser = require('xml2json'); let xmlString = `<?xml version="1.0" encoding="UTF-8"?> <TestScenario> <TestSuite name="TS_EdgeHome"> <TestCaseName name="tc_Login">dt_EdgeCaseHome,dt_EdgeCaseRoute</TestCaseName> <TestCaseName name="tc_Logout">dt_EdgeCaseRoute</TestCaseName> ...

407 Authentication Required Npm

Answer : I recommend reading through this article to configure the proxy for npm. http://wil.boayue.com/blog/2013/06/14/using-npm-behind-a-proxy/ npm config set proxy http://proxy.company.com:proxyport npm config set http-proxy http://proxy.company.com:proxyport npm config set https-proxy http://proxy.company.com:proxyport Hope this is useful for you! Usually, when you are behind a corporate proxy, it is needed to add the domain where you are at. Given that also the characters should be URL encoded, it would look like: https://domain%5Cusername:password@proxy:port We should add proxy with username and password to avoid this error. For example: username: admin password: admin123 proxy: 172.10.3.21 port: 3128 npm config set proxy http://admin:admin123@172.10.3.21:3128 npm config set https-proxy http://admin:admin123@172.10.3.21:3128

Can Yarn Be Considered A Viable Option As A Replacement For Bower And Npm?

Answer : It depends on your exact use case, but... probably . Currently, the major trend seems to be towards module bundlers such as Webpack and Browserify (and hence either npm or Yarn) and away from Bower. You can read an excellent overview of the situation at NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack, along with some reasons why you might want Webpack instead of Bower. At the minute, you're probably using HTTP, where it works out faster to have one JavaScript bundle file rather than lots of source files (as would occur with Bower). That's why Webpack and Browserify are so popular (among other reasons) — they should increase performance and simplify development a lot. Side note: HTTP/2 will diminish the value of module bundling, because multiple requests will become far less costly. See What is the value of using Webpack with HTTP/2 for a more detailed description of the issues involving HTTP/2. If you use npm or Yarn, it shouldn't really m...