Issues when creating new angular 7 project - node.js

Error while creating the new project using angular cli. Tried npm clear cache --force and manually deleted the npm cache folder. None of them worked.
No proxy required for connecting internet
ng new testapp--routing
> node-sass#4.11.0 install C:\Users\user\testapp\node_modules\node-sass
> node scripts/install.js
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-72_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.11.0/win32-x64-72_binding.node":
HTTP error 404 Not Found
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
> node-sass#4.11.0 postinstall C:\Users\user\testapp\node_modules\node-sass
> node scripts/build.js
Building: C:\Program Files\nodejs\node.exe C:\Users\user\testapp\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [
gyp verb cli 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'C:\\Users\\user\\testapp\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library='
gyp verb cli ]
gyp info using node-gyp#3.8.0
gyp info using node#12.0.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError ```

Just create new project as:
ng new testapp
Then remove your angular cli and clear cache and please again
npm install -g #angular/cli
And build and run your project.

Sometimes due to global installation of many library you will get the above error. No need to create new project. Please perform the following steps
Step 1: Try to do the npm i again. if you are ending up with error then go to step 2
Step 2: $ npm install -g node-sass
And finally, one last check:
$ node-sass -v
Then perform step 1 again if needed ( optional).
Once the node-sass installation is successful then you wont face this error going forward.
Hope this will help

I was having pretty much the same problem. I'm guessing you are selecting SCSS as the stylesheet format? I got a bit further than you before it ended in compile errors but would not work all the way. I solved my problem by downgrading to node version 11. It seems node-sass 4.11 does not support node version 12. See Error installing node-sass.
The download error is shown because there is no such file. The latest version time of writing at github is win32-x64-67_binding.node.
I also think that you might have a dependency problem with Python. Have a look at node-gyp configuration - windows and make sure you have all the dependencies.
Hope this helps!

Related

How do I make npm install work when it can't find my python installation?

npm install fails and my goal is to get it to succeed.
I have Python 2 installed, but it is located at /usr/bin/python2 and not /usr/local/bin/python2.
I get the following error message when running npm install.
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library='
gyp verb cli ]
gyp info using node-gyp#3.8.0
gyp info using node#14.2.0 | darwin | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "/usr/local/bin/python2" in the PATH
gyp verb `which` failed Error: not found: /usr/local/bin/python2
What should I do about it?
One of the simplest things you can try is a symlink from the actual location of the python2 executable to the location where npm is expecting it.
# create symlink
ln -s /usr/bin/python2 /usr/local/bin/python2
# test executability of symlink
/usr/local/bin/python2 --version
Once you've created that symlink, retry npm install in your project.

Prebuilt node-sass for alpine linux not used

As I understand node-sass packages has a prebuilt binary for Alpine Linux as noted on releases page but for some reason when I run yarn install it tries to compile it from the source.
What could be the reason for that? Is this a yarn bug?
yarn install v1.5.1
warning package.json: No license field
warning emulsify#1.0.0: No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents#1.1.2: The platform "linux" is incompatible with this module.
info "fsevents#1.1.2" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
error An unexpected error occurred: "/var/www/html/node_modules/node-sass: Command failed.
Exit code: 1
Command: sh
Arguments: -c node scripts/build.js
Directory: /var/www/html/node_modules/node-sass
Output:
Building: /usr/local/bin/node /var/www/html/node_modules/node-gyp/bin/node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ '/usr/local/bin/node',
gyp verb cli '/var/www/html/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.6.2
gyp info using node#9.11.1 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing \"build\" directory
gyp verb command configure []
gyp verb check python checking for Python executable \"python2\" in the PATH
gyp verb `which` failed Error: not found: python2
I'm posting the answer since a hidden comment isn't good enough for most people :
uninstall NPM and reinstall v8.11, nvm may have upgraded it.

Angular2 applicatoin node-sass install error

My application was running fine but all of sudden showing the following error when i try npm i. my node version is: v6.10.3 and npm version: 3.10.10
npm WARN prefer global node-gyp#3.6.2 should be installed with -g
> node-sass#4.7.1 install C:\Projects\Latest_Nov20\FrontEnd\OdyssEY-UI-Core\node_modules\node-sass
> node scripts/install.js
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'C:\\Users\\2024522\\AppData\\Roaming\\npm\\node_modules\\node-sass\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.6.2
gyp info using node#6.10.3 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (C:\Users\2024522\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (C:\Users\2024522\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (C:\Users\2024522\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:80:29)
gyp verb `which` failed at C:\Users\2024522\AppData\Roaming\npm\node_modules\node-sass\node_modules\which\which.js:89:16
gyp verb `which` failed at C:\Users\2024522\AppData\Roaming\npm\node_modules\node-sass\node_modules\isexe\index.js:42:5
gyp verb `which` failed at C:\Users\2024522\AppData\Roaming\npm\node_modules\node-sass\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:123:15)
gyp verb `which` failed python2 { Error: not found: python2
Downloading binary from https://github.com/sass/node-sass/releases/download/v4.7.1/win32-x64-48_binding.node
Cannot download "https://github.com/sass/node-sass/releases/download/v4.7.1/win32-x64-48_binding.node":
tunneling socket could not be established, cause=getaddrinfo ENOTFOUND empweb2.ey.net empweb2.ey.net:80
Hint: If github.com is not accessible in your location
try setting a proxy via HTTP_PROXY, e.g.
export HTTP_PROXY=http://example.com:1234
or configure npm proxy via
npm config set proxy http://example.com:8080
> node-sass#4.7.1 postinstall C:\Projects\Latest_Nov20\FrontEnd\OdyssEY-UI-Core\node_modules\node-sass
> node scripts/build.js
I was trying installing nvm and uninstalled nvm. only after this, i am getting this error.
Can anyone help me what am i doing wrong here?
Thanks
I have faced and fixed this issue relates node-sass and python error.Try installing latest angular cli command with the steps below
Set the system variable path as well:
C:\Users\windowsusername\AppData\Roaming\npm
C:\Users\windowsusername\AppData\Roaming\npm\node_modules\#angular\cli\bin;
C:\Program Files\nodejs;
Then start using angular cli command prompt using:
angular client project folder path>npm install -g #angular/cli#latest
angular client project folder path>npm install -g node-gyp

Error running JHipster Registry

I'm trying to start JHipster Registry by building it from source and for that I'm following Matt Raible's tutorial.
But I'm getting an error with exit code 1 and the following is the generated stack trace.
yarn install v0.27.5
[1/4] Resolving packages...
[2/4] Fetching packages...
warning fsevents#1.1.1: The platform "win32" is incompatible with this module.
info "fsevents#1.1.1" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
warning "angular2-cookie#1.2.6" has incorrect peer dependency "#angular/common#^2.0.0".
warning "angular2-cookie#1.2.6" has incorrect peer dependency "#angular/core#^2.0.0".
warning "ng2-translate#4.2.0" has incorrect peer dependency "#angular/core#^2.0.0".
warning "ng2-translate#4.2.0" has incorrect peer dependency "#angular/http#^2.0.0".
[4/4] Building fresh packages...
[1/4] ⢀ node-sass: could not find "C:\Users\Srikar\AppData\Local\Programs\Python\Python35\python.EXE". checking
[-/4] ⢀ waiting...
[3/4] ⠠ phantomjs-prebuilt: Receiving...
[-/4] ⠠ waiting...
error D:\JHipster\jhipster-microservices-example\registry\node_modules\node-
sass: Command failed.
Exit code: 1
Command: C:\WINDOWS\system32\cmd.exe
Arguments: /d /s /c node scripts/build.js
Directory: D:\JHipster\jhipster-microservices-example\registry\node_modules\node-sass
Output:
Building: C:\Program Files\nodejs\node.exe D:\JHipster\jhipster-microservices-example\registry\node_modules\node-gyp\bin\node-gyp.js rebuild --verbose --libsass_ext= --libsass_cflags= --libsass_ldflags= --libsass_library=
gyp info it worked if it ends with ok
gyp verb cli [ 'C:\\Program Files\\nodejs\\node.exe',
gyp verb cli 'D:\\JHipster\\jhipster-microservices-example\\registry\\node_modules\\node-gyp\\bin\\node-gyp.js',
gyp verb cli 'rebuild',
gyp verb cli '--verbose',
gyp verb cli '--libsass_ext=',
gyp verb cli '--libsass_cflags=',
gyp verb cli '--libsass_ldflags=',
gyp verb cli '--libsass_library=' ]
gyp info using node-gyp#3.6.0
gyp info using node#8.3.0 | win32 | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` failed Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\JHipster\jhipster-microservices-example\registry\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\JHipster\jhipster-microservices-example\registry\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:152:21)
gyp verb `which` failed python2 { Error: not found: python2
gyp verb `which` failed at getNotFoundError (D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:13:12)
gyp verb `which` failed at F (D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:68:19)
gyp verb `which` failed at E (D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:80:29)
gyp verb `which` failed at D:\JHipster\jhipster-microservices-example\registry\node_modules\which\which.js:89:16
gyp verb `which` failed at D:\JHipster\jhipster-microservices-example\registry\node_modules\isexe\index.js:42:5
gyp verb `which` failed at D:\JHipster\jhipster-microservices-example\registry\node_modules\isexe\windows.js:36:5
gyp verb `which` failed at FSReqWrap.oncomplete (fs.js:152:21) code: 'ENOENT' }
gyp verb check python checking for Python executable "python" in the PATH
gyp verb `which` succeeded python C:\Users\Srikar\AppData\Local\Programs\Python\Python35\python.EXE
gyp verb check python version `C:\Users\Srikar\AppData\Local\Programs\Python\Python35\python.EXE -c "import platform; print(platform.python_version());"` returned: "3.5.4\r\n"
gyp verb could not find "C:\Users\Srikar\AppData\Local\Programs\Python\Python35\python.EXE". checking python launcher
gyp verb could not find "C:\Users\Srikar\AppData\Local\Programs\Python\Python35\python.EXE". guessing location
gyp verb ensuring that file exists: C:\Python27\python.exe
gyp ERR! configure error
gyp ERR! stack Error: Can't find Python executable "C:\Users\Srikar\AppData\Local\Programs\Python\Python35\python.EXE", you can set the PYTHON env variable.
gyp ERR! stack at PythonFinder.failNoPython (D:\JHipster\jhipster-microservices-example\registry\node_modules\node-gyp\lib\configure.js:482:19)
gyp ERR! stack at PythonFinder.<anonymous> (D:\JHipster\jhipster-microservices-example\registry\node_modules\node-gyp\lib\configure.js:508:16)
gyp ERR! stack at D:\JHipster\jhipster-microservices-example\registry\node_modules\graceful-fs\polyfills.js:284:29
gyp ERR! stack at FSReqWrap.oncomplete (fs.js:152:21)
gyp ERR! System Windows_NT 10.0.16251
gyp ERR! command "C:\\Program Files\\nodejs\\node.exe" "D:\\JHipster\\jhipster-microservices-example\\registry\\node_modules\\node-gyp\\bin\\node-gyp.js" "rebuild" "--verbose" "--libsass_ext=" "--libsass_cflags=" "--libsass_ldflags=" "--libsass_library="
gyp ERR! cwd D:\JHipster\jhipster-microservices-example\registry\node_modules\node-sass
gyp ERR! node -v v8.3.0
gyp ERR! node-gyp -v v3.6.0
gyp ERR! not ok
Build failed with error code: 1
info Visit https://yarnpkg.com/en/docs/cli/install for documentation about this command.
Steps performed:
1) Download the JHipster Registry from Github as a zip and Unzip it.
2) Navigate to that directory in the Windows PowerShell and run yarn or yarn install.
I'm new to JHipster. I'm not sure whether the issue is with sass or python2 or other. I'm looking for detailed information regarding the issue and how to solve it?
Node Version: 8.3.0
Power Shell Version: 5.1.16251.0
OS ->
Edition: Windows 10 Enterprise Insider Preview
Version: 1703
OS Build: 16251.1002
[As far as I can understand,
i) Warning with fsevents is because I'm using Windows x-64 and fsevents is mainly for Mac to monitor file systems. Is that correct?
ii) Is the registry using Angular 2 for the front-end design? (even though you can build Angular 4 apps with JHispter)
iii) When building fresh packages, node_sass complains it cannot find the python.exe file but I've checked the folder but the file exists. I have python3.5.4 in the path too.
In the subsequent steps, is it looking for python2 because it didn't find python3? If JHipster is a SpirngBoot(back-end) + Angular(front-end) application then where will the python be used? Can we write mild python scripts too?]
i) correct you can ignore this warning
ii) the registry is an app generated by JHipster (you can see its options in .yo-rc.json file) and uses angular 4 for its UI
iii) python is only used for node building not by the app runtime, here the issue is with node-sass that cannot be built and it's an environment issue:
node-gyp requires python 2.x to build native module like node-sass and you have python 3.x, please re-install
JHipster recommends using an LTS version of Node currently 6.x, you're using latest currently 8.x, please consider re-installing.
Now, the bad news is that you are on Windows; best platforms for nodejs are Linux and macOS, Matt Raible is on macOS so he did not encounter all your issues. It's possible that even with fixing your python and nodejs versions node-gyp may fail building native modules. If this happens you have few alternatives:
use jhipster-devbox
don't use sass and select a tutorial that doesn't use it
install MS build tools
I just downgrade NodeJS to 6.x and things started to work out. So, please, try downgrade it and recompile using: yarn.

NPM downloads nodejs each time

I use fedora, so I had nodejs and npm installed from the repos.
But I needed to install SailsJS which asked for newer versioon of npm, so I did a sudo npm install npm -g, but after that installing each package takes a lot of time and in verbose mode I can see that each time nodejs is fetched and compiled (even though my fedora already has the same version installed). Some output :
npm verb linkBins utf-8-validate#1.1.0
npm verb linkMans utf-8-validate#1.1.0
npm verb rebuildBundles utf-8-validate#1.1.0
npm verb rebuildBundles [ 'bindings', 'nan' ]
npm info install utf-8-validate#1.1.0
> utf-8-validate#1.1.0 install /lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate
> node-gyp rebuild
gyp info it worked if it ends with ok
gyp verb cli [ 'node',
gyp verb cli '/usr/lib/node_modules/npm/node_modules/node-gyp/bin/node-gyp.js',
gyp verb cli 'rebuild' ]
gyp info using node-gyp#2.0.2
gyp info using node#0.10.36 | linux | x64
gyp verb command rebuild []
gyp verb command clean []
gyp verb clean removing "build" directory
gyp verb command configure []
gyp verb check python checking for Python executable "python2" in the PATH
gyp verb `which` succeeded python2 /bin/python2
gyp verb check python version `python2 -c "import platform; print(platform.python_version());"` returned: "2.7.10\n"
gyp verb get node dir no --target version specified, falling back to host node version: v0.10.36
gyp verb command install [ 'v0.10.36' ]
gyp verb install input version string "v0.10.36"
gyp verb install installing version: 0.10.36
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp WARN EACCES user "root" does not have permission to access the dev dir "/root/.node-gyp/0.10.36"
gyp WARN EACCES attempting to reinstall using temporary dev dir "/lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate/.node-gyp"
gyp verb command install [ 'v0.10.36' ]
gyp verb install input version string "v0.10.36"
gyp verb install installing version: 0.10.36
gyp verb install --ensure was passed, so won't reinstall if already installed
gyp verb install version not already installed, continuing with install 0.10.36
gyp verb ensuring nodedir is created /lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate/.node-gyp/0.10.36
gyp verb created nodedir /lib/node_modules/strongloop/node_modules/ws/node_modules/utf-8-validate/.node-gyp
gyp http GET https://nodejs.org/dist/v0.10.36/node-v0.10.36.tar.gz
gyp http 200 https://nodejs.org/dist/v0.10.36/node-v0.10.36.tar.gz
gyp verb extracted file from tarball deps/zlib/zlib.h
gyp verb extracted file from tarball deps/zlib/deflate.h
gyp verb extracted file from tarball deps/zlib/inflate.h
gyp verb extracted file from tarball deps/zlib/zutil.h
gyp verb extracted file from tarball deps/zlib/examples/gzlog.h
gyp verb extracted file from tarball deps/zlib/crc32.h
gyp verb extracted file from tarball deps/zlib/inffast.h
gyp verb extracted file from tarball deps/zlib/trees.h
gyp verb extracted file from tarball deps/zlib/gzguts.h
Your issue seems to have the solution proposed here :https://github.com/TooTallNate/node-gyp/issues/610
Basically you have to download node v0.10.36 in the .node-gyp directory.

Resources