Posts

Showing posts with the label Npm

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'"

Cannot Uninstall Angular-cli

Answer : I have also faced the same issue in recent past for me I have do the following commands one by one in terminal. sudo npm uninstall -g angular-cli sudo npm cache clean After this run ng -v If still get angular-cli version 1.0.0-beta.2x.x then run the following command which ng It will show the ng path. Go to the path and if it is linked with any file remove the same the link and actual ng file. In my case the link is in /usr/bin/ng and actual path of ng file is /lib/node_modules/@angular/cli/bin/ng. sudo rm -rf /lib/node_modules/@angular/cli/bin/ng sudo rm -rf /usr/bin/ng Next you need to install @angular/cli using sudo npm install -g @angular/cli Close all the terminal and run ng -v and you are on. May be it will help someone. Thanks :) Updating Angular CLI https://github.com/angular/angular-cli#updating-angular-cli If you're using Angular CLI 1.0.0-beta.28 or less, you need to uninstall angular-cli package first. npm uninstall -g angular-cli ...

-bash: Sequelize: Command Not Found

Answer : The reason is: sequelize is not installed globally on your cli. To get sequelize access to all your cli just do. npm install -g sequelize-cli The '-g' means global this will allow you to access sequelize command anywhere in your app directory. After that you can do eg: sequelize model:generate --name User --attributes firstName:string,lastName:string,email:string,password:string Had the same issue, then noted that sequelize-cli is the way to go ahead. npm install -g sequelize-cli I would like to answer my own question. The global npm install path was wrong for my computer. npm config get prefix Then I ran to put the path where it should be. This problem gave me a lot of head aches. Hope it helps someone. npm config set prefix /usr/local

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=...

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...

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

Check If Npm Package Is Installed In Package.json Through Terminal

Answer : you can check easily for that. this will describe all the package installed globally npm list -g --depth=0 this will describe all the package installed locally on your project. npm list --depth=0 if you want to check for a particular module is installed or not. Please use the following command in project folder. if installed, will display package name and version installed. if not installed, then will not display anything. npm list --depth=0 | grep <module_name> for more detail information please see this link. Click here for more info of your question --depth=0 is necessary so that your terminal isn't flooded with package dependencies. if you are not use this option, you will see the all the dependencies tree. If you are searching for specific package installed in your project, you can use one of the commands below based on what kind of terminal you use. If you are using Unix shell based terminal, you can use: npm list --depth=0 | grep <module...

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.

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...