Unable to create a new project with the Nest CLI - javascript

I am following this tutorial to create a nest project. I have installed Nest CLI using this command:
npm i -g #nestjs/cli
I have checked the list of packages installed locally using the following command and found that it was successfully installed:
npm list -g --depth 0
but when I tried to create a new project using following command it gave me an error:
nest new project-name
Error:
nest : The term 'nest' is not recognized as the name of a cmdlet, function, script file, or
operable program. Check the spelling of the name, or if a path was included, verify that the
path is correct and try again.
At line:1 char:1
nest new project-name
+ CategoryInfo : ObjectNotFound: (nest:String) [], CommandNotFoundException
+ FullyQualifiedErrorId : CommandNotFoundException
Screenshot:
Why it is so? What's wrong with it? Can someone assist me in identifying the issue?
Thanks in advance

In most cases, it is better to use npx instead of installing global npm packages, since you'll always use the latest version and not clutter your file system with things you don't need often.
Just replace nest with npx #nestjs/cli for any command:
npx #nestjs/cli new project-name

Try installing latest npm using:
npm install npm#latest -g
It worked for me. Also found a related answer here:
https://github.com/nestjs/nest-cli/issues/223

In Windows 10, I was able to resolve this by adding npm installation directory to windows PATH environment variable.
My npm global installation path was
C:\Users\<user.name>\AppData\Roaming\npm

For many cases you have to manage environment variables manually. For windows;
Right click Start,
Click System,
Click Advance system settings on the right section under Related settings,
System Properties setting will pop up. In Advanced tab, click Environment Variables,
In user variables search for path variable. Click edit,
Click Browse and find npm folder path (%AppData%\Roaming\npm) click add.
Close all pop up windows by clicking OK and that's it.
Close any opened terminal, PowerShell etc.
Open new terminal or PowerShell and type nest -v press Enter.
If you see the version then everything is fine.

Install the latest version of node then nest new project-name will work.
If it's not the case then use npx #nestjs/cli new project-name instead.

Related

npx create-nuxt-app <project-name> not working

I want to create Nuxt.Js app using npx. But i am getting following error.
You have a space in your Windows username. This is a problem with NPX.
This is the path that NPM sees (which is right)
This is the path that NPX sees (which is wrong)
You can fix it by changing your NPM-Cache to another directory (without a space in the path):
npm config set cache C:\your\new\path\npm-cache --global
Source:
https://github.com/zkat/npx/issues/146#issuecomment-384016791
I changed npm-cache directory by writing following command
npm config set cache C:\tmp\nodejs\npm-cache --global
After that npx create-nuxt-app <project-name> worked perfectly.
I had it working using this command.
npm init nuxt-app <project-name>
This problem was resolved in a reddit
https://www.reddit.com/r/vuejs/comments/ie8vab/createnuxtapp_not_working_anyone_else_had_this/
Install it with:
npm i -g create-nuxt-app
Usually npm/npx should propose you to install, but it might not work
This issue can appear if during first try the installation was aborted
I have encountered similar problem and I have multiple spaces in the username.
If the above solutions does not work for you on Windows, there is another way.
Run VS code editor as an administrator.
Open the integrated terminal by clicking on Terminal > New Terminal or by pressing CTRL + SHIFT + '
Instead of using npx use the following
npm init nuxt-app project-name
Point number 3 will only work if you run the VS code editor as Administrator.
I am sure it is the same with external terminals. Run CMD/Gitbash as Administrator
Hope this helps. :D

ng command not working [duplicate]

I am trying to create a project (named ngadmin) via the angular cli but it throws errors on this command: ng new ngadmin. The errors are:
fs: re-evaluating native module sources is not supported. If you are
using the graceful-fs module, please update it to a more recent
version.
You cannot use the new command inside an angular-cli project.
I am not sure what the problem is as this cli was working fine for me a few days ago.
Check in your username folder, if there is package.json and node_module exist. If they are there then delete them.
Notice: you may have created an angular project in your home/username directory. If you delete them it will work.
If using Linux, go to home and delete package.json.
I had this problem as well. Here is how I fixed it:
Go to package.json
Under "Dependencies", find "angular-cli": "^1.0.0-beta.18"
Delete this line ("angular-cli": "^1.0.0-beta.18")
Save file
Hope that helps!
The first warning regarding graceful-fs is due to the fact that angular-cli uses older version of graceful-fs pkg, nothing to worry about that.
The error "You cannot use the new command inside an angular-cli project" signifies you are inside an angular cli project, get out of the angular cli project using cd .. command and try running the command ng new ngadmin it will work.
there is a file package.json
Simply remove it and then Create project.
it will work for sure
Seems like i fixed my problem. I have no idea what happened but i noticed system32 was not in my PATH so i added that and uninstalled and reinstalled the angular-cli package. everything works like a charm now
I had the same issue, the thing was I was not closely following along the tutorial I was watching and I tried using the same directory, I used cd .. to move up in the file structure and it worked like a charm, hope this helps!
i had the same problem today, I started a fresh project and did
npm install -save #angular/cli
and received the error.
I just renamed the package.json to .json2 temporarily and it worked.
Delete the file package.json in current directory where you are trying to create. Then try to install again.
In windows cd/User,Find the package.json,package-lock.json file and delete both the files.
Restart your command prompt and you are ready to go.And try to use this command
npm install --save-dev #angular/cli#latest
You must have used local "npm install #angular/cli" command to install angular locally in your project.
Uninstall local angular using "npm uninstall #angular/cli"
install angular globally using "npm install -g #angular/cli"
and then try "ng new ngadmin"
Because "ng new projectName" will automatically install angular/cli locally as a dev-dependency

Cannot find module 'crawler'

After installing node-crawler in Node.js (not in the default directory) via the npm command, I tried to run the code in the "Usage" section but an error occurs when executing var Crawler = require("crawler"); and the VisualStudio Code debug console says Cannot find module 'crawler'.
Does it happen because I installed crawler in a custom location? How can I fix this?
npm install will install a package locally. (--save to have package appear in your dependencies.)
To have access to it from everywhere, you need to install it globally, using npm install -g
Maybe I found the solution. I replaced "crawler" in var Crawler = require("crawler"); with the path that points to the crawler.js file in the lib folder in node-modules, and now the code works. Maybe it happened because I installed crawler in a custom location and so VisualStudio couldn't find "crawler".

Bower: ENOGIT Git is not installed or not in the PATH

Git is installed and is in the path.
Platform: Red Hat Enterprise Linux 5.8.
>which git
/usr/local/bin/git
Yet bower can't find it:
bower angular#1.0.6 ENOGIT git is not installed or not in the PATH
What is the recommended work-around?
Adding Git to Windows 7/8/8.1 Path
Note: You must have msysgit installed on your machine. Also, the path to my Git installation is "C:\Program Files (x86)\Git". Yours might be different. Please check where yours is before continuing.
Open the Windows Environment Variables/Path Window.
Right-click on My Computer -> Properties
Click Advanced System Settings link from the left side column
Click Environment Variables in the bottom of the window
Then under System Variables look for the path variable and click edit
Add the pwd to Git's binary and cmd at the end of the string like this:
;%PROGRAMFILES(x86)%\Git\bin;%PROGRAMFILES(x86)%\Git\cmd
Now test it out in PowerShell. Type git and see if it recognizes the command.
Source: Adding Git to Windows 7 Path
Just use the Git Bash instead of cmd.
Run the following command at your node.js command prompt where "<git path>" is the path to your git bin folder:
set PATH=%PATH%;<git path>;
So, like this:
set PATH=%PATH%;C:\Program Files\Git\bin;
Or this: (Notice the (x86) )
set PATH=%PATH%;C:\Program Files (x86)\Git\bin;
This will add git to your path variables. Be sure you type it correctly or you could possibly delete your path vars which would be bad.
Make sure you installed Git with the second or third option selected from the list. It will penetrate the Git command to cmd by modifying PATH automatically ;)
I had the same error in Windows. Adding git to the path fixed the issue.
G:\Dropbox\Development\xampp\htdocs.penfolds.git\penfolds-atg-development>bower install
bower bootstrap#~3.0.0 ENOGIT git is not installed or not in the PATH
G:\>PATH
PATH=E:\Program Files\Windows Resource Kits\Tools\;
G:\Dropbox\Development\xampp\htdocs.penfolds.git\penfolds-atg-development>set PATH=%PATH%;E:\Program Files\Git\bin;
G:\Dropbox\Development\xampp\htdocs.penfolds.git\penfolds-atg-development>bower install
bower bootstrap#~3.0.0 not-cached git://github.com/twbs/bootstrap.git#~3.0.0
bower bootstrap#~3.0.0 resolve git://github.com/twbs/bootstrap.git#~3.0.0
I am also getting the same error and the solution is first to check if the Git is installed or not in the system and if not please install it.
After installation, open Git Bash or Git Shell from Windows and go to your project (same way you go in command prompt using "cd path"). Git Shell is installed by default with Github windows installation.
Then run the same bower install command. It will work as expected.
The below screenshot shows the command using Git Shell
On Windows, you can try to set the path at the command prompt:
set PATH=%PATH%;C:\Program Files\Git\bin;
When you ran the git install, you probably didn't choose:
"Use Git from the Windows Command Prompts"
during the installation.
Re-run git install, and choose that option.
You are missing the ENVIRONMENT PATH. Follow these steps:
Search for 'Edit the system environment variables'.
Click on 'Environment Variables'.
In the 'System variables' section, scroll down and click on the variable 'Path'. Click 'Edit'.
Append this text to the end of the 'Variable value'.
;%PROGRAMFILES%\Git\bin;%PROGRAMFILES%\Git\cmd
I also got the same problem from cmd and resolved using the following steps.
First install the https://msysgit.github.io/ (if not alredy installed).
Then set the Git path as suggested by skinneejoe:
set PATH=%PATH%;C:\Program Files\Git\bin;
Or this (notice the (x86)):
set PATH=%PATH%;C:\Program Files (x86)\Git\bin;
In Linux:
if you dont have installed git use:
sudo apt-get update
sudo apt-get install git
with command which git you will know the directory where is and then add in path if it is not in that enviroment variable.
I bumped into this problem on a cPanel CentOS 6 linux machine.
The solution for me was to symlink the cPanel git to /usr/local/bin/git
ln -s /usr/local/cpanel/3rdparty/bin/git /usr/local/bin/git
1.Set the Path of Git in environment variables.
2.From Windows command prompt,
run cd Project\folder\Path\
run the command: bower install
People above already gave solutions for your proplem, I hope so. If someone is facing this issue in 2022 in using docker images, then you should add a command to install git in your image.
For Example you are using alpine image in your Dockerfile. Then it will be something like this :
FROM node:8.3-alpine
# ....... other stuffs .....
RUN apk add git
# ....... other stuffs .....
I solved the problem by install Git Bash from Download Git Bash.
Setting this option 3 when installing the software as shown bellow.
Finally select the project folder by right click using Bash as shown below.
and type
npm install
. It works for me.
npm install from git bash did work for me.
After rebooting PC.
Just use the Git Bash instead of node.js or command prompt
As an Example for installing ReactJS, after opening Git Bash, execute the following command to install react:
bower install --react
I had the same problem and needed to restart the cmd - and the problem goes away.

Bower "Git not in the PATH" error

I just installed git and bower via NPM for a project. It's a first time use.
Then I tried running bower install jQuery for example, I get this specific error:
ENOGIT git is not installed or not in the PATH
Where can I actually define paths and how, and when we say PATHs, what's the main idea?
Also, I really need help with some good resources for learning the concept behind this question or learning NPM usage in general.
I'm using windows 7, 64-bit.
Install msysgit, as stated in the Bower documentation:
To use Bower on Windows, you must install msysgit correctly. Be sure to check the option shown below:
[ ] Use Git bash only
[x] Run Git from the Windows Command Prompt
[ ] Run Git and included Unix tools from the Windows Command Prompt
After the installation has completed, restart CMD. You (and bower) will then be able to run git from the command prompt, which will fix your issue.
Make sure u installed git with 2nd or 3rd option selected from list.
It will penetrate git command to cmd by modifying PATH automatically ;)
Manual method is to add the Git cmd path to your windows PATH environment variable. The Git cmd path will be unique on your machine, and something like:
C:\Users\<YourUserName>\AppData\Local\GitHub\PortableGit_<SomeGuid>\cmd\
From command prompt, add it to your PATH var like so:
path C:\Users\<YourUserName>\AppData\Local\GitHub\PortableGit_<SomeGuid>\cmd\;%PATH%
Install Bower using Git Bash and run bower install jQuery from Git Bash. Git doesn't work from Windows command prompt as CMD is not POSIX compatible.
Forget powershell and command prompt. Use git bash and it works like normal.
Make sure you use the "Git bash" in that directory but not the command terminal of the system:like this
First install git on your pc, if you do not add the path then add it yourself
C:\Program Files\Git\cmd

Categories