Troubles with Angular CLI installing - javascript

I have installed node (v 8.5.0) with npm (5.3.0).
After that I made: npm install -g #angular/cli but it doesn't work:
ng help
-bash: ng: command not found
here are installation logs:
MacBook-Air:~ michael$ npm install -g #angular/cli
/Users/michael/.npm-global/bin/ng -> /Users/michael/.npm-global/lib/node_modules/#angular/cli/bin/ng
+ #angular/cli#1.4.3
updated 1 package in 39.276s

You can check out this issue on github.
It seems like they are running npm install again possibly needing admin privileges as well.

Related

Error while using create react app command

Even though everything used to work couple of weeks ago, now I can not successfully create new react app with its templates.
When I try to run npx create-react-app my-app command, it only creates the folder with package.json, pckage-lock.json and node_modules. The public folder is missing and also, when I try to run npm start, it gives me an error saying:
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
before it used to say happy hacking and the template page with react logo was displayed.
I tried to uninstall and install node again, clear cache but nothing helped. Any advice? Thank you so much!
My npm -v is 6.13.4 and node -v is v12.14.0
If you have installed create-react-app globally. remove that globally from you system
Try these steps
npm uninstall -g create-react-app
npx create-react-app app_name
cd app_name
npm start
Note- npx comes with npm 5.2+ and higher, see instructions for older
npm versions
Check this reactjs documentation.
Faced the same issue and fixed it by following the below steps:
Try to uninstall all existing global installation of create-react-app and check that they are removed properly by using the two commands below:
command for uninstalling: npm uninstall -g create-react-app
command for checking: which create-react-app
command for manual delete: rm -rf <path where create react app is located>
Once all the versions are removed, use: npx create-react-app <name_of_the_app>
For more details refer here
First, update the npm and node using following commands:
npm install -g npm
npm cache clean -f
npm install -g n
n stable
Remove globally installed create-react-app using:
npm uninstall -g create-react-app
Use npx for using create-react-app directly:
npx create-react-app <project-name>
I was having the same issue, and saw a lot of the same answers saying to uninstall create-react-app globally and reinstall using npx create-react-app my-app.
Downgrading my version of Node to 8.11.1 is what fixed it.
sudo npm install -g n
sudo n 8.11.1
node -v
> v8.11.1
After that I ran npx create-react-app my-app and it worked as expected.

nest Command not found

I followed the documentation to create my first NestJS project.
Installing the Nest CLI with the command npm i -g #nestjs/cli was successful.
The output was:
+ #nestjs/cli#6.3.0
updated 1 package in 11.326s
However, when I try to scaffold a project with the Nest CLI:
nest new project-name
I get the following error:
zsh: command not found: nest
Some details about my environment:
OSX
iTerm
npm version 6.5.0
Use npx #nestjs/cli instead of nest
e.g. npx #nestjs/cli g controller pages
I was also getting the same console error when npm installing!
Erro was
#nestjs/cli
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#nestjs/cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#nestjs
npm WARN notsup Unsupported engine for watchpack-chokidar2#2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"12.14.1","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2#2.0.0
How I wasn able to install =>
Solution
sudo npm install -g #nestjs/cli
Following command works in my windows 10
node -v
v14.16.0
npm -v
6.14.11
npx #nestjs/cli new project-name
I was having the same issue, what I did was:
Installed the latest node with npm install npm#latest -g
and then added the following to my .bash_profile
alias nest="/usr/local/Cellar/node/11.9.0/bin/nest"
Tested with nest --version and it worked.
For some reason the path is not being called correctly, hope it helps.
Working through a NestJS/Mongo DB tutorial i stumbled into this very same problem. After trying all of the solutions that were listed above, even turning my default profile back to bash instead of using zsh, i found that simply adding the /usr/local/bin and ~/.npm-global/bin to my path variable resolved the issue. Hopefully this helps someone else who may stumble on this in the future as well.
export $PATH="/usr/local/bin"
export $PATH="~/.npm-global/bin"
Were the two commands i ran from iTerm2 in order to add them to my PATH environment variable. Once this was done a simple
env
showed the entries in my $PATH environment variable and the nest -v command worked without any issues.
I had same error when I use GitBash.
I resoved it:
If you use windows:
Your use CMD: npm i -g #nestjs/cli
Then you can use gitbash:
Check version nestjs: nest --version
Create app nestjs: nest new name_project
I have faced same problem and solved ,following this
write the command NPM root -g
check where NPM is installed
add it to your path environment variable
You have to add the following line to your ~/.zshrc file:
source $HOME/.bashrc
This is needed so that the npm binaries are available on startup.
After all the answers that I tried, I used my method
After installing npm i -g #nestjs/cli in my mac terminal.
open bash file in macos by typing open ~/.bash_profile in mac terminal. Like you can type it anywhere.
Your bash will look like this and use this line
alias nest="~/.npm-global/lib/node_modules/#nestjs/cli/bin/nest.js"
Restart your mac for changes to be reflected in your terminal.
There you go nestjs cli is now working globally 2nd screenshot.
I have just succeeded with
npx #nets/cli new project
when asked what manager to choose from npm / yarn / pnpm
made choice for pnpm
cd project
npm run start
Take care!
Must use sudo in comandline for linux, otherwise the command nest cannot be add to /usr/local/bin folder:
sudo npm install -g #nestjs/cli
You can try to use sudo
sudo yarn global add #nestjs/cli
I got the same issue.
I just uninstalled and reinstalled nextjs.
Finally, I can use next -v

Module not found (webpack)/hot/emitter #angular-devkit/build-angular after ionic serve - Ionic 4

Stack:
node v10.15.1
ionic 4.10.1
When I run ionic serve I get:
ERROR in (webpack)/hot/emitter.js [ng] Module not found: Error: Can't
resolve 'events' in
'/zazou/node_modules/#angular-devkit/build-angular/node_modules/webpack/hot'
Failed to compile.
Couldn't find an answer for this.
I tried to:
update #angular-devkit/build-angular
npm install webpack-hot-dev-clients
npm install -g webpack and npm install -g webpack-dev-server as suggested here
npm link wepack
I also tried to update my angular CLI
Similar question
Install events using npm.
npm install events
Or to save other people (e.g. repository users), run:
npm install events --save --dev
(same pb with angular 7, using angular/cli)
I don't have THE solution (as I don't really understand the issue), but after a lot of tries, it worked, so let me describe what I did, maybe it'll help you...
swicth to node 9.5.0 (used n to do it)
switching to npm 5.6.0
remove global webpackage (I installed it for a try to solve version..)
npm uninstall webpack -g
rm -rf node_modules
npm install
then an issue with rxjs-compat, so I installed the version 6.4.0 for rxjs and rxjs/compat
Then it worked...
Maybe executing one of these steps will help you...
I also encountered this (when updating to Angular 11). To fix I had to:
rm -rf node_modules
rm package-lock.json

'ng new my-app' error

I am trying to generate a new project and skeleton application using the latest version of Angular. I have tried uninstalling and reinstalling Angular CLI using:
C:\>npm install -g #angular/cli#latest
C:\>ng --version
#angular/cli: 1.4.5
node: 8.8.1
os: win32 x64
This error occurs when trying to run 'ng new my-app' in command prompt:
'Error: The command "new" has an option without the required type and name field'
Any help to resolve this issue is appreciated.
This is a known issue and there is an issue raised in github for this.
https://github.com/angular/angular-cli/issues/7984
Try below commands:
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#latest
After these steps:
npm uninstall -g #angular/cli
npm cache clean
npm install -g #angular/cli#latest
Do:
npm install #schematics/angular
And then:
ng new appname

npm: not found when setting up Jenkins Server?

This is my first time setting up a jenkins server. The build is using Amazon's EC2 and Ubuntu 14.04.
I've installed node and npm via nvm.
node -v
>v0.11.14
npm -v
>2.0.0
The repo pulls down just fine into my /var/lib/jenkins/workspace/morningharwood folder.
Problem: When I add my script it breaks
Here's my build script which errors out? I have no idea what i'm doing. I copied this from a tutorial.
QUESTION: How do I properly write my script to npm install, bower install and lastly, grunt test
You could install node, npm, bower and grunt by doing following:
sudo apt-get install node
sudo npm install bower
sudo npm install grunt
To install a package from local source, use
npm install /path
Try using NodeJS plugin for Jenkins: https://wiki.jenkins-ci.org/display/JENKINS/NodeJS+Plugin
This will solve npm command not found issue on jenkins even installed on server
sudo mkdir /usr/local/nvm
export NVM_DIR=/usr/local/nvm
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.34.0/install.sh |NVM_DIR=/usr/local/nvm bash
. /usr/local/nvm/nvm.sh
nvm install 10.15.3 -g
npm install #angular/cli -g
Include following on build execute shell command in jenkins:
export PATH="$PATH:/usr/local/nvm/versions/node/v10.15.3/bin"
npm install

Categories