Can't generate scaffolding with Yeoman - node.js

I'm following this tutorial to scaffold an application with generators (webapp and angular). I can install all dependencies and generators but when I run the commands yo webapp or yo angular I don't get any output feedback and when I run ls nothing was generated. When I diplay the npm installed packages with npm -g list I can see yo, bower and grunt packages are installed.
I'm using Ubuntu 13.04 64 bits and npm, yo, bower and grunt are installed in the usr/lib/node_module directory. I've checked some posts and questions about possible installation/directory problems but I can really get what's the real problem. Did I miss something during the instalation?
UPDATE
I tried installing all in Windows 7 and it works. So I think there are installation problems on Ubuntu, but I can't still figure out how to fix that.

You installed node, the Amateur Packet Radio Node program, instead of nodejs.
Run apt-get remove node && apt-get install nodejs and everything will be fine.

Related

Install Yarn after NPM

I need some help and clarification regarding Yarn installation process.
MacOS ver. 10.14.2
I've installed Homebrew via official site (ver. 2.0.1).
I've installed NPM by downloading package from official site (ver. 10.15.1 LTS).
Now when I tried to install yarn via brew install yarn
I have the following error:
The post-install step did not complete successfully
You can try again using `brew postinstall node`
As I undertand, NPM installs node locally, when, for instance, I try to use create-react-app. When I use Homebrew to install yarn, it tries to install node globally. And we have conflict here.
I've found suggestion to use:
sudo chown -R `whoami`:admin /usr/local/
I am not entirely sure what this command does.
So, the questions are:
Why changing the owner of the folder should be a solution? How will it affect multi user system?
What is the correct way to install yarn?
Can be there any conflicts if node is installed globally and locally (app folder.)
P.S. Please correct me, if I have wrong understanding here.
As Trott points out, npm does not install Node. npm is a package manager that comes bundled with Node. If you install Node, you automatically install npm.
Why changing the owner of the folder should be a solution? How will it affect multi user system?
It's not. Changing the permissions of this folder is sometimes suggested as a workaround for when you have npm installed in a location owned by root. This can cause EACCES errors when you try to install packages globally.
What is the correct way to install yarn?
While you can install Yarn through the Homebrew package manager, I would recommend doing: npm install -g yarn.
Can be there any conflicts if node is installed globally and locally (app folder).
You can't install Node globally and locally. You can install multiple versions of Node on the same machine, however.
I'm not a big fan of having one global Node installation, as it makes it a pain to update (esp. if one application relies on an older version of Node) and, depending on how you install Node, it can lead to permissions errors.
The better way is to use a version manager. This will allow you to install multiple Node versions on your machine, avoid permissions errors and swap between these Node versions at will.
I would recommend using nvm. It works nicely on MacOS. The TL;DR for installing nvm is:
curl -o- https://raw.githubusercontent.com/creationix/nvm/v0.34.0/install.sh | bash
But I would encourage you to look at the project on GitHub and read its README. There is also a good tutorial on how to use it here.
Once you have Node installed using nvm, run npm install -g yarn to install Yarn globally and you should be off to the races.
Finally, you might want to read this tutorial on using npm, as it could help to clear up some of the concepts.
HTH
I have faced a problem after install yarn by running npm install -g yarn command in my OS Windows 10 Pro. That was showing yarn' is not recognized as an internal or external command operable program or batch file.
Whatever, I have found the solution:
After npm,
go to CMD from your windows PC,
write : *npm install -g yarn*
then,
Go to Environmental Variables set up.
Edit Path and add new and paste:
C:\Users\User\AppData\Roaming\npm\node_modules\yarn\bin\
Restart your terminal. And then check again in your cmd by running :
*yarn* or *yarn --version*

Setting Up Node & NPM

I have installed MEAN IO a few times. Everytime I get it installed I can usually get one project going and then things just stop working. For example I have one project going. But then when I go to create a new project now it says commands are not found
gulp
mean init myApp
bower
So I installed with the installer at https://nodejs.org/en/
export PATH="/usr/local/bin:/usr/local/sbin:~/bin:$PATH"
I have node_modules at
usr/local/lib/node_modules
But I also have packages at
/usr/local/bin/
Either way I cant get these commands to run... Any ideas how I can get things setup and solid?
Try installing mean-cli, bower and gulp globally, like so:
npm install -g mean-cli bower gulp

npm install bower using -g vs --save-dev

I'm new to node and using npm to both do some node, angular and Express tutorials. I have used bower before in a tutorial. I'm pretty sure I have installed it using -g already as when i run the bower -v command I get back 1.3.3 I am to understand that installing it using -g means, Install this globally so that on the next project I don't have to install it again.
1) Is this correct?
2) When I start working with a new project do I have to initialize bower?
3) Is there any reason I should use install bower --save-dev after I have already installed bower (-g)lobally?
4) What exactly does install bower --save-dev do?
I have searched and get nothing on google or stack over flow when I search "--save-dev".
I really want to understand this and if you help me, it will help me understand installing much more than just bower and how to use those installs. Again, I'm new to the command line for this type of development and new to these technologies, but have some basic understanding.
Using the --save and --save-dev flags when installing will add them to the project's package.json. This allows anyone who might develop on or use the project to install the dependencies as needed with a simple npm install command. By contrast, the -g flag is global only to your local machine.

NPM appears to do nothing on Linux Mint 15

searched, and did not see this specific problem.
Trying to get a MEAN stack built on my Linux Mint machine, and bumping into a bit of an unusual issue.
Got MongoDB installed, and finally got it running correctly (none of the instructions ANYWHERE mentioned having to create the /data/db/ directory and set permissions, go figure).... it works now.
Got NodeJS installed, and it appears to work correctly.
I had been told (apparently incorrectly) that NPM installs right alongside Node, with:
sudo apt-get install nodejs
but:
$ npm
bash: /usr/bin/npm: No such file or directory
So I go ahead and install NPM separately.
$ sudo apt-get install npm
Seems to work, so far, no errors, and it looks like it is pulling down the NPM package and installing it...
$ nodejs -v
v0.10.21
$ npm -v
$
?? It simply fails to respond without any error... so I try:
$ npm install grunt -g --save-dev
$
Same completely silent failure... in fact, NOTHING I could do gets a response out of NPM.
Looked all over the web, and saw nothing similar anywhere... found out that NPM holds its cache files in ~/.npm and noticed that this folder didn't exist (kinda like the mongo issue above), so I created it, and set permissions to 7777... still nothing.
Purged and re-installed both node and npm, tried installing them both together and separately (yes, desperation)... still no love.
WTF am I doing wrong?
I would love, eventually, to have a nice development environment setup, hopefully with Cloud9 as a local IDE.... but already pulling my hair out.
=========================================================================================
OK, after a few more headaches, this is up and built now... thank you all.
Would love to mark both as answers, but it won't let me.
npm does come with node. Where is apt-get pulling it from? I install the Mac OS X packages on my Mac for development and npm does in fact come with it. I compile from source on my CentOS server and npm comes with it.
Your package provider may be providing them separately as a (in)convenience to you.
As for why your npm command does not work after installation, I can't say for sure, but I am suspicious of your use of --save-dev and -g together.
-g means to install globally, which means 2 things:
It will be installed outside of your npm package's structure into a system location like /usr/bin or /usr/local/bin
It requires root access to install. Did you use sudo to run it with root access?
Both of those requirements conflict with --save-dev which records the package as a dependency in your package.json file so that future npm install commands will install that package within the project space.
That said, I happen to know a lot about grunt. It has 2 parts, a globally installed tool and the package-specific tool. The correct way to install it is:
$ [sudo] npm install -g grunt-cli
$ npm install grunt --save-dev
This will install the grunt-cli package into a system location guaranteed to be in the $PATH, which turns around and looks for a package-specific grunt installed which is not system-wide.
When installing nodejs with npm, this one-liner worked for me.
sudo apt-get install nodejs nodejs-dev npm
I don't believe npm comes with the nodejs installation in the apt repo. Try to install npm separately using the following tutorial http://www.giantflyingsaucer.com/blog/?p=1688 'To install NPM ....'
====== Edit ====
node and npm IS separate. Follow the official wiki and everything should be fine

compass:server not found when running `grunt server`

The problem
grunt server outputs this:
Warning: Task "compass:server" not found.
I uploaded Gruntfile.js here: https://gist.github.com/ComFreek/7289648
That's the default file I got after creating a new Yeoman project.
Details
I am reading Building Web Apps With Yeoman And Polymer and following the described console commands to run.
My system:
Windows 8.1 Pro 64-bit
NodeJS 0.10.21
NPM 1.3.11
I've already executed these commands:
npm install -g yo
npm install generator-polymer -g
yo polymer
grunt server told me that I had to install Ruby and Compass.
I installed Ruby from here:
http://rubyinstaller.org/
After installing, I also successfully whether Ruby has really been registered in the PATH.
I used NPM for installing Compass:
npm install grunt-contrib-compass --save-dev -g
(I tried a local and global install of Compass. Neither of them worked.)
This is the exact output of grunt:
D:\test>grunt server
Running "server" task
Warning: Task "compass:server" not found. Use --force to continue.
Aborted due to warnings.
Elapsed time
server 4ms
Total 4ms
It works now...
Unfortunately, I still don't know the exact cause. I went through all of my instructions above again, and it just worked out of the box.
In any case, I recommend updating all packages. My version numbers are (last edited: 02.02.14):
[NodeJS v.0.10.24]
[NPM 1.3.21]
[grunt-cli v0.1.11]
[grunt v0.4.2]
I had the same problem but it was fixed after I've installed Ruby's compass:
# gem install compass
Hint: gem is the package manager for Ruby, so Ruby should be existing in the system.
For Redhat's based linux systems, you can use the following to install Ruby and gem:
# yum install gcc ruby-devel rubygems
# gem install compass
For Debian's based linux systems, you can check this
Install compass with the following command:
npm install -g compass
If you've installed node as a sudo user (which is not recommendable), you should add sudo to the command (and next time use NVM)
sudo npm install -g compass
Install Ruby, add to env -> path variable, add to pathtext as per link below
http://www.tutorialspoint.com/ruby/ruby_installation_windows.htm
Then install compass in ruby.
Only this solved the issue
The only thing that worked for me was:
npm install ruby-compass.
I had previously installed compass like Paul said but didn't work.

Resources