How to install yo on node#12 and npm#6.9.0 with zshrc via homebrew - npm

I have been trying to install yo to integrate and test botkit but had issues with yo and npm and node as I updated brew on my mac to the latest. Here is how I resolved it.

If you have installed latest node 12 on your mac using latest update of homebrew(if you haven't updated and want to, please update brew by running brew update and run brew install node).
Run the following commands to verify node and npm are updated to 12 and 6.9.0
[keshav#xxxxxx-mbp ~ ]$node -v
v12.1.0
[keshav#xxxxxx-mbp ~ ]npm -v
6.9.0
If this is what you see on your console, you are good to proceed to next steps.If not, please add a comment if you are facing a error.
Run the following commands
echo export PATH="$HOME/npm/bin:$PATH" >> ~/.zshrc
npm config set prefix ~/npm
echo "export NODE_PATH=$NODE_PATH:/home/$USER/npm/lib/node_modules" >> ~/.zshrc && source ~/.zshrc
npm install -y -g yo
Once you run the command in step 4, you should see the below output in the console.
Output of command 4
npm install -y -g yo
npm WARN deprecated cross-spawn-async#2.2.5: cross-spawn no longer requires a build toolchain, use it instead
/Users/xx/npm/bin/yo-complete -> /Users/xx/npm/lib/node_modules/yo/lib/completion/index.js
/Users/xx/npm/bin/yo -> /Users/xx/npm/lib/node_modules/yo/lib/cli.js
yo#2.0.6 postinstall /Users/xx/npm/lib/node_modules/yo
yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ NODE_PATH matches the npm root
✔ yo version
Everything looks all right!
+ yo#2.0.6
updated 1 package in 5.752s

Related

install packages globally in google cloud platform

I'm trying to install some npm packages globally in google cloud platform each time the shell started.
I added these commands in $HOME/.customize_environment file.
#!/bin/sh
date -u
npm i -g #angular/cli
then, I open the file /var/log/customize_environment to see the log output from $HOME/.customize_environment
I found it executed and the date is displayed (the first line)
but npm couldn't installed with this error npm command not found
npm commands are available after the cloud shell starts, so I guess the file $HOME/.customize_environment is executed before installing node.
I tried to use the full path: /usr/local/nvm/versions/node/v12.14.1/bin/npm i -g #angular/cli, but I got this error
/usr/bin/env: ‘node’: No such file or directory
is there a way to automatically install npm packages globally?
The path env var isn't set or active. Use the full path of NPM location like that
/usr/local/nvm/versions/node/v12.14.1/bin/npm i -g #angular/cli
Be careful. if Cloud Shell update the version of NPM the path will change.
You can also try to add your NPM (without full path) command at the end of the ~/.bashrc file.

How install and run vue js application on Centos 7

I want to install vuejs and run it on Centos 7, I want to run it inside a specific folder.
[updated]
It's a little bit different, but works fine to me on CentOS 7
(deprecated but working fine)
$ curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
$ sudo yum install -y nodejs
$ node --version
$ npm --version
$ sudo npm install -g #vue/cli
$ vue create [projectname]
go to the folder of project name:
$ cd projectname
$ npm run serve
open your internet browser and type http://localhost:8080/
You need to install Node and NPM first. On CentOS 7 you can do this by running the following commands.
curl -sL https://rpm.nodesource.com/setup_10.x | sudo bash -
sudo yum install nodejs
After this, confirm that Node and NPM are installed by running node --version and npm --version.
Then you need to install vue-cli. This makes creating Vue applications very easy. Install it by running npm install -g #vue/cli. After that has installed, you can create new projects by running vue create <project-name>. Once you have created the project, you can run it locally using npm run serve.

ng new didn't work, showing blank terminal screen

I want to create my first Angular project. I have a problem at the beginning, because when i go to the project folder and type:
ng new my-first-project
Nothing happens. I only see blank terminal:
My:
npm -v: 6.4.1
node -v: 10.11.0
ng -v: Mg++ version:
Mg++ 1.5beta1 (formerly MicroGnuEmacs Adv.)
I tried:
sudo npm uninstall -g angular-cli #angular/cli
npm cache clean
sudo npm install -g #angular/cli
but nothing has changed. I also tried the same with node 8.x.x however, the effect was the same.
I working on Ubuntu 16.0.4 and my default system language is different than English.
Try this
mkdir ~/.npm-global
npm config set prefix '~/.npm-global'
export PATH=~/.npm-global/bin:$PATH
source ~/.profile
Run this command in your terminal
export PATH=~/.npm-global/bin:$PATH
This is my solution. I Solve it installing last version node with nvm.
nvm install node --reinstall-packages-from=node
npm install -g #angular/cli

npm install runs correctly, but cannot run topojson

If I do:
npm init
npm install --save topojson
I end up with a package.json file and node_modules directory, all looking correct. But if I then do:
topojson
I see:
-bash: topojson: command not found
Why?
The answer to this issue turned out not to be related to npm - npm install topojson no longer installs a command-line tool called topojson. Confusingly, it used to, but the package has changed.
try this step
install globally using -g
1. install nodejs http://nodejs.org/
2. install npm https://npmjs.org/doc/README.html
3. run npm install -g topojson in your command prompt
4. use the command prompt to cd to the geojson file
5. run topojson -o myNewTopojsonFile.json myOldGeojsonFile.json

Command not found with vue-cli

While installing the dependencies of vue-cli, vue is not identified. Why?
rm -rf node_modules and npm install again
have a look here
Add sudo before yarn when installing
yarn global remove #vue/cli
sudo yarn global add #vue/cli
vue
I had the same issue for a while.
TL;DR
npm install #vue/cli-service --save-dev
As the documentation specify it is a development dependency https://cli.vuejs.org/guide/#cli-service
The CLI Service (#vue/cli-service) is a development dependency. It's an npm package installed locally into every project created by #vue/cli.
Origin
I had a fresh install of nodejs
And just did
>> sudo npm install -g #vue/cli#latest
>> vue --version
#vue/cli 4.5.8
The issue
The issue presented like this
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
/bin/sh: 1: vue-cli-service: not found
error Command failed with exit code 127.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
The fixes:
npm install #vue/cli-service --save-dev
Which led me straight to another error message
>> npm run serve
yarn run v1.22.10
$ vue-cli-service build --mode development --watch
ERROR Error: Cannot find module 'vue-template-compiler/package.json'
Which I fixed the same way
npm i vue-template-compiler --save-dev
And now it is working fine.
Installing current version without permanently installing vue-cli.
npx #vue/cli create appname
It shows the vue executable is located at /home/alisha/.local/bin. So probably this location is not there in your $PATH.
You should be able to run the vue commands if you provide the full path, like:
~/.local/bin/vue create hello-world
You can also see if that directory is in your PATH by running some command like:
echo $PATH | grep '.local/bin/'
If it's there, you would see it, otherwise you can add it to your path by placing it in your ~/.profile.
Edit ~/.profile and add the following at the bottom of it.
PATH="$HOME/.local/bin:$PATH"
Hope it helps!!
I had the same issue while making a build for production.
You will require vue-cli to be installed. Use below command to install the latest version.
npm install -g #vue/cli#latest
Then
npm install
Might have to do with you having an old version on your computer:
Warning regarding Previous Versions
The package name changed from vue-cli to #vue/cli. If you have the previous vue-cli (1.x or 2.x) package installed globally, you need to uninstall it first with
npm uninstall vue-cli -g or yarn global remove vue-cli.
You can find it here: https://cli.vuejs.org/guide/installation.html
THIS FIXED THE ISSUE FOR ME:
After running
sudo npm install -g #vue/cli
I ran
sudo nano $HOME/.profile
and pasted the following line
export PATH=$PATH:/home/chike/.npm-global/bin
after writing the code, next thing I did was Ctrl + O, ENTER and Ctrl + X then wrote
vue init webpack myapp
When you install vue using cli that time you got the path of vue.Now you can copy the bin folder path.
In my example /home/sublime/.npm-packages/bin
Now you export the path below command
export PATH=$PATH:/home/sublime/.npm-packages/bin
I solved mine by running (add sudo if needed)
npm i -g vue-cli#2.9.6
npm i -g #vue/cli
Got similar issue when deploy vue project in jenkins.
Here is what I did:
Add node's bin/ dir, to jenkins user's .bashrc file.
e.g
# node
NODE_HOME=/home/dev/.nvm/versions/node/default
PATH=$NODE_HOME/bin:$PATH
Tips - about nvm & yarn
When you manage node version via nvm, make sure you already choose the node version in terminal. e.g:
nvm use stable
node -v
If you use nvm, and installed yarn via npm, then better install vue-cli via npm not yarn, otherwise the vue executable is not placed into node's bin/ dir, at least that's the case in my tests, and as a result will cause you fail to find the vue command.
Using Yarn on Ubuntu it is installed to ~/.npm-packages/bin/. You must add this directory to your PATH. For example run the following command, close your terminal and open a new one.
user#machine:~$ echo 'export PATH="$PATH:~/.npm-packages/bin/"' >> ~/.bashrc
Note: if the file ~/.bashrc does not exist then simply create it.
Following worked for me:
First remove all the existing ones:
yarn global remove #vue/cli
yarn global remove #vue/cli-service
sudo yarn global remove #vue/cli
sudo yarn global remove #vue/cli-service
Then add #vue/cli using sudo:
Note: use sudo if required
yarn global add #vue/cli
yarn global add #vue/cli-service
Then, the final thing to do is to RESTART the terminal.
vue --version
#vue/cli 4.5.9
If you already got a project, the only two things you need to do is:
Delete the directory node_modules (it is safe, since it is not under git and will regenerate in the next step)
In the command-line write yarn install (it will install everything you need)
If you start installing vue-cli manually in a existing project, it the package.json and package-lock.json will be updated. If you already did. Do a checkout from git, and follow my steps above
This may be a problem caused by version conflicts. "export PATH=$PATH:" This is really useful in some cases. But if you are also like me, after trying the direct “export path” method in the comment above, restarting the terminal still can not execute the situation, you can try this way.
Uninstall Vue
npm uninstall -g #vue/cli
Check the local-global npm package installation path, vue is installed in this directory, check if it has been removed.
npm root -g
Install vue (you can check with https://cli.vuejs.org/#getting-started to find the latest command)
npm install -g #vue/cli
Create a connection to the /usr/local/bin directory(You need to find the vue.js path after the local installation first, then replace this path with your latest local install path:/Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js)
ln -s /Users/xxxxx/.npm-global/lib/node_modules/#vue/cli/bin/vue.js /usr/local/bin/vue
View version number
vue -v
I was getting the same error because Node.js was not installed. My issue got resolved by installing Node.js using the following command:
sudo apt install nodejs-legacy
To see if you already have Node.js and npm installed and check the installed version, run the following commands:
node -v
npm -v
If both are installed then follow the steps here:
https://docs.npmjs.com/resolving-eacces-permissions-errors-when-installing-packages-globally
I installed the package using yarn global add #vue/cli on my Ubuntu box and found the binary in /home/vonkad/.yarn/bin.
I had to modify my /home/vonkad/.bashrc and add the directory to the path export PATH=$PATH:/home/vonkad/.yarn/bin.
To fix this situation, I had to add the following line to my .zshrc (maybe in your case is .bashrc)
export PATH="$(yarn global bin):$PATH"
Effectively, the yarn global bin is a folder where vue (vue-cli 3) was placed.
What helped me
mac os catalina with zsh terminal
Uninstalled node and npm using https://www.positronx.io/how-to-uninstall-node-js-and-npm-from-macos/
Downloaded node/npm from https://nodejs.org/en/download/current/
sudo npm install -g #vue/cli
vue --version (#vue/cli 4.5.4)
I faced the same issue and now resolved. In my case I installed Node.js and NPM using the default Ubuntu repository by using this command sudo apt-get install nodejs npm
The problems seemed like those 2 packages are not well maintained so it caused some bugs.
So I purge those packages and reinstall it from nodesource which is officially recommended way to install (reference: Installation instruction from nodesource) using these commands.
curl -sL https://deb.nodesource.com/setup_14.x | sudo -E bash -
sudo apt-get install -y nodejs
Then reinstall #vue/cli again
sudo npm install -g #vue/cli
Now these issues have gone. Hope it helps some programmers.
You need to install vue via sudo like explained in the doc:
https://cli.vuejs.org/guide/installation.html
If you have WSL2 running and you use zsh like me, just add
yarn global add #vue/cli
# add this line to ~/.zshrc
export PATH="$HOME/.yarn/bin:$PATH"
$ vue --version
#vue/cli 4.x.xx
You can try the following code install see
npm install --global vue-cli
vue init webpack <YOUR-PROJECT-NAME-HERE>
cd <YOUR-PROJECT-NAME-HERE>
npm install
npm run dev