4

i am getting error, The system cannot find the path specified. when adding test new project into node.js command prompt getting error. I am totally confused to create new project.

Your environment has been set up for using Node.js 12.14.1 (x64) and npm.

C:\Users\user>npm install -g @angular/cli
C:\Users\user\AppData\Roaming\npm\ng -> C:\Users\user\AppData\Roaming\npm\node_m
odules\@angular\cli\bin\ng

> @angular/cli@8.3.22 postinstall C:\Users\user\AppData\Roaming\npm\node_modules
\@angular\cli
> node ./bin/postinstall/script.js

+ @angular/cli@8.3.22
updated 1 package in 59.885s

C:\Users\user>ng new test
The system cannot find the path specified.

I am using operating system window 8.1 pro version In my system below variables added

1) User variables for user

NODE_PATH: C:\Users\user\AppData\Roaming\npm\node_modules

Path:C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;%USERPROFILE%.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;%AppData%\npm;;C:\Program Files (x86)\Microsoft VS Code\bin;%AppData%\npm;C:\Program Files\nodejs\;C:\Users\user\AppData\Roaming\npm

2) System variables

Path:%SystemRoot%\system32;%SystemRoot%;%SystemRoot%\System32\Wbem;%SYSTEMROOT%\System32\WindowsPowerShell\v1.0\;C:\Program Files (x86)\Windows Kits\8.1\Windows Performance Toolkit\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\Tools\Binn\;C:\Program Files\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files (x86)\Microsoft SQL Server\100\Tools\Binn\VSShell\Common7\IDE\;C:\Program Files (x86)\Microsoft Visual Studio 9.0\Common7\IDE\PrivateAssemblies\;C:\Program Files (x86)\Microsoft SQL Server\100\DTS\Binn\;C:\Program Files\Microsoft\Web Platform Installer\;%USERPROFILE%.dnx\bin;C:\Program Files\Microsoft DNX\Dnvm\;C:\Program Files\Microsoft SQL Server\120\Tools\Binn\;%AppData%\npm

Mr doubt
  • 51
  • 1
  • 10
  • 42
  • Are you on a Windows machine or a Mac? – tomerpacific Jan 12 '20 at 15:49
  • i am on windows. @tomerpacific – Mr doubt Jan 12 '20 at 15:57
  • Have you tried looking at [this](https://stackoverflow.com/questions/39190164/npm-the-system-cannot-find-the-path-specified/51279032)? While it refers to the npm command, the same error as yours shows up. – tomerpacific Jan 12 '20 at 16:00
  • Your link has not helped I am using window 8.1 pro version. @tomerpacific – Mr doubt Jan 31 '20 at 05:16
  • I'm not familiar with this step in the installation process `node ./bin/postinstall/script.js` (and this path does not exist in my angular install), what purpose does it serve? Any chance that script changes any paths? Because other that line, this looks like a standard angular install and should work correctly. – JDunken Feb 04 '20 at 16:25
  • `ng version` from the command line gives versioning information? – JDunken Feb 04 '20 at 16:38
  • no, C:\Users\user>ng version 'ng' is not recognized as an internal or external command, operable program or batch file.@JDunken – Mr doubt Feb 04 '20 at 19:03
  • Well, if you have no way of adding angular to the system path then you're not going to be able to use the cli, but you shouldn't need to manually modify the system path variable. I would suggest you first uninstall the package and try installing it again, this time without running the post install `script.js` and see if it works. And if that doesn't work, see if your sysadmin can help you out to modify the path. If this is your computer, you should not have a problem adding angular to the system path variable. – JDunken Feb 04 '20 at 19:21
  • 1
    I'm assuming you've closed the console that you installed from at some point and opened a new one and it's still not working? (sometimes the console needs to be restarted for new path variables to be available to it, although I've not had that problem installing angular). – JDunken Feb 04 '20 at 19:28
  • since ng version also not working, I guess your environment variables hasn't configured properly. Try this solution. It may work for you. https://stackoverflow.com/questions/45329744/ng-is-not-recognized-as-an-internal-or-external-command/46874999#46874999 – Nimezzz Feb 04 '20 at 20:04
  • try downgrading node version to ~10. – SourceCodeBot Feb 05 '20 at 07:34
  • Have you tried executing ng on this path C:\Users\user\AppData\Roaming\npm just to check if ng command is identified as valid command. – Ravikant Chaudhary Feb 05 '20 at 09:32
  • Reinstall node and reinstall the angular cli. If 'ng' is not known there might have been something wrong with either installations. Also, you should be able to do `ng new` in any console ie Powershell/cmd/visualcode terminal – Samuel Middendorp Feb 05 '20 at 10:41
  • can you please post the results of running `echo %PATH%` in your terminal. – Nijeesh Joshy Feb 05 '20 at 11:11
  • 1
    Add environment variables and check – Akhil Aravind Feb 05 '20 at 12:03
  • 1
    @mohdmazharkhan can you check this question: https://stackoverflow.com/questions/39190164/npm-the-system-cannot-find-the-path-specified – Hope Feb 06 '20 at 11:53
  • try npm list -g . Check if is installed in your global packages – CREM Feb 07 '20 at 15:12
  • | | +-- inherits@2.0.4 | | +-- minimatch@3.0.4 | | | `-- brace-expansion@1.1.11 | | | +-- balanced-match@1.0.0 | | | `-- concat-map@0.0.1 | | +-- once@1.4.0 | | | `-- wrappy@1.0.2 deduped | | `-- path-is-absolute@1.0.1 | `-- winston@2.1.1 | +-- async@1.0.0 | +-- colors@1.0.3 | +-- cycle@1.0.3 | +-- eyes@0.1.8 | +-- isstream@0.1.2 | +-- pkginfo@0.3.1 | `-- stack-trace@0.0.10 `-- stable@0.1.8. @Carlos – Mr doubt Feb 07 '20 at 19:29
  • if you don't see angular/cli on the list you are not going to be able to invoke ng command – CREM Feb 07 '20 at 21:31
  • try again npm list -g --depth 0 : avoid including every package’s dependencies in the tree view – CREM Feb 07 '20 at 21:39

4 Answers4

0

Try to run the following commands:

  1. npm install -g npm@latest
  2. npm config set script-shell bash

After that, run the ng new command again.

  • I tried your two command after that i did: C:\Users\user>ng -v 'ng' is not recognized as an internal or external command, operable program or batch file. @Brontosaurs – Mr doubt Feb 07 '20 at 19:07
  • i did not use run as administrator, normally open command promt. @Quethzel – Mr doubt Feb 08 '20 at 07:56
0

Just want to rule out the possibility of Path corruption. Please try the following:

rem for future
setx NODE_PATH %AppData%\npm\node_modules
rem for current session
set NODE_PATH=%AppData%\npm\node_modules
setx path "%path%;%AppData%\npm"
ng -v

Modified version to the original answer: https://stackoverflow.com/a/9588052/639107

kn_pavan
  • 1,510
  • 3
  • 21
  • 42
  • I tried all your commands : C:\Users\user>setx NODE_PATH %AppData%\npm\node_modules SUCCESS: Specified value was saved. C:\Users\user>set NODE_PATH=%AppData%\npm\node_modules C:\Users\user>setx path "%path%;%AppData%\npm" SUCCESS: Specified value was saved. C:\Users\user>ng -v 'ng' is not recognized as an internal or external command, operable program or batch file. @kn_pavan – Mr doubt Feb 07 '20 at 19:21
  • If nothing helps. I would rather suggest clean-up everything and install Node through `nvm` for windows. – kn_pavan Feb 10 '20 at 06:56
0

Not sure if you are actually creating a project called test.

At least until 8.0 it was impossible to create a project with the name test. You'd get some warning about an invalid project name. Try to create another project with another name. cli-test for example.

Robin Dijkhof
  • 18,665
  • 11
  • 65
  • 116
0

If nothing works then have a fresh setup. unintsall node and all then install everything you need. make sure abouth PATH

TheRakeshPurohit
  • 551
  • 1
  • 6
  • 22