Unable to Install Ionic on Windows - node.js

I'm meant to be maintaining an Ionic app, but I cannot install Ionic on any of my machines (neither at work - Win 7) nor at home (Win 10).
Perhaps we could start with my home machine (Win 10). After the fail, I uninstalled Node completely, and restarted the machine. I re-installed Nodejs and upgraded npm such that the versions are:
Nodejs: 10.4.1
NPM: 6.1.0
The output from my Powershell prompt (at elevated privileges) is:
PS F:\Code\Powershell\Toolkit> npm install -g ionic
npm ERR! path C:\Users\roger\AppData\Roaming\npm\node_modules\ionic\node_modules.readable-stream.DELETE
npm ERR! code ENOTEMPTY
npm ERR! errno -4051
npm ERR! syscall rmdir
npm ERR! ENOTEMPTY: directory not empty, rmdir 'C:\Users\roger\AppData\Roaming\npm\node_modules\ionic\node_modules.readable-stream.DELETE'
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\roger\AppData\Roaming\npm-cache_logs\2018-06-17T01_32_39_358Z-debug.log
Interestingly, the directory .readable-stream.DELETE referred to as being not empty, is empty. So, not sure what is going on there.
Any help would be great.
Thanks

First thing to do is sort out that directory deletion issue. Make sure you uninstall Nodejs to make sure none of its processes are locking that directory.
Try the following.
Right-click the drive upon which that directory is located (probably C drive).
Click Properties on the Context Menu
Go to the Tools tab
Click the Check button.
Let it run its course. Once complete, if all looks well, try deleting the directory again.
If that succeeded, install Node again (v8.11.3). Don't upgrade NPM.
Install Ionic again with npm install -g ionic
Create an app ionic start myApp tabs
Change to the myApp directory.
Run ionic serve
Hopefully the first part will clear away that folder and get you on your way.

Related

Cannot npm install --save electron because group policy prevent CMD execution in %appdata% folder

Issue
Our group-policies does not allow to execute cmd files from the windows %appdata% folder. When I try to install electron this error happens:
npm install --save electron
npm ERR! code 1
npm ERR! path C:\data\dev\dy\we\quick-start\node_modules\electron
npm ERR! command failed
npm ERR! command C:\WINDOWS\system32\cmd.exe /d /s /c C:\Users\X\AppData\Local\Temp\postinstall-a836babe.cmd
npm ERR! Blocked by group policy. Please contact your system administrator (translated).
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\X\AppData\Local\npm-cache\_logs\2022-09-06T09_22_56_569Z-debug-0.log
Tried solution
Overrule the installation path by adding
prefix = 'C:\data\dev\npm-global'
into C:\Users\X\.npmrc file, but the error persits.
Question
Is there any possibility, to change the usage of %appdata% to a custom folder like C:\data\dev\npm-global ?
Since there is always a dynamic electron-a86xxxx.cmd file downloaded it is not possible to whitelist a specific file for the %appdata% folder.
Used Versions
Node: v16.17.0
NPM: 8.15.0
EDIT 1
npm get prefix outputs this C:\data\dev\npm-global
EDIT 2
npm config list outputs this prefix = "C:\\Users\\X\\AppData\\Roaming\\npm" ; overridden by user
EDIT 3
Found another .npmrc config file in C:\Program Files\nodejs\node_modules\npm and updated it as well.
EDIT 4
Executing npm install -g electron results in the same error. NPM always wants to run a CMD file from the %appdata% folder.
EDIT 5
It seems like the command npm install -g electron did work and does put the files into the C:\data\dev\npm-global folder. But electron still wants to execute the cmd file from the appdata folder.
EDIT 6
The issue seems to be with the postinstall-xxxxxxx.cmd which seems to be electron specific. I already installed NodeJS into C:\data\dev\NodeJS but the electron installation still wants to execute a cmd from the appfolder.
I ran into the same problem you're having with npm 8.15.0, albeit with a different package. I upgraded to the latest non-LTS release, which at the time of this writing is node 18.10.0 and npm 8.19.2, and the issue went away.
I do have the following set in .npmrc. I don't know if they made a difference (it still failed with npm 8.15.0), as I haven't tried without them there. I do know npm states it ignores the tmp config value, so it may not be needed.
tmp=C:\some\safe\dir\npm
cache=C:\some\safe\dir\npm-cache

React npm start issue -- ELIFECYCLE, errno1

Any time I try to run npm start I get an error saying:
npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! dbproject#0.1.0 start: set PORT=9999 && react-scripts start npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the dbproject#0.1.0 start script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
So far I've tried:
-Changing environment variables, my current environment variables are these
-Cleaning the npm cache, deleting the node_modules and then running npm install again
-I tried running npm start in different project folders, none of the React projects work, they all throw the same error. Node servers run well, I haven't tried running anything else.
Pastebin of the full console log: https://pastebin.com/P8DDDaDq
Pastebin of the debug.txt file: https://pastebin.com/1ebezKX2
I'm running Windows 10 Home Build 17134.
I would be extremely grateful of any help
Problem solved!
Leaving the solution that worked for me here in case it is helpful for anyone.
Here's what I did:
1.- Uninstall node
2.- Restart your computer
3.- Install node again
4.- Install React running npm install -g create-react-app
5.- Create a new React project folder running npm create-react-app yourProjectName, place all your project files here except for the node_modules folder and the package.json files
6.- After you have done that install all of your dependencies manually with npm, it should work fine now!

Can't install Ember Octane on Mac; problems with NPM and NVM

I'd like to install the most recent version of Ember on my Mac with MacOS Catalina. I actually thought I had done so a few weeks ago (this machine is only three months old), but ember -v says that Ember CLI is at version 3.9 which is 13 months old.
So I entered npm install -g ember-cli in the terminal, but I get an error:
npm ERR! Error: EACCES: permission denied, access '/usr/local/lib/node_modules'
npm ERR! { [Error: EACCES: permission denied, access '/usr/local/lib/node_modules']
npm ERR! stack:
npm ERR! "Error: EACCES: permission denied, access '/usr/local/lib/node_modules'",
npm ERR! errno: -13,
npm ERR! code: 'EACCES',
npm ERR! syscall: 'access',
npm ERR! path: '/usr/local/lib/node_modules' }
npm ERR!
npm ERR! The operation was rejected by your operating system.
npm ERR! It is likely you do not have the permissions to access this file as the current user
So I did what is suggested here and tried to install nvm:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.35.3/install.sh | bash
There's some output and everything is looking finde, but when I try to verify my installation using command -v nvm, there's no output at all.
npm uninstall ember-cli gives me up to date in 0.031s.
What can I do to get Ember Octane running?
edit: I managed to install NVM using Homebrew. nvm -v says 0.35.3. But I don't find any information on how to continue from here. I still get the same error when trying to install Ember.
Your problem lies in your comment:
npm bin says /Users/<my-username>/node_modules/.bin. which ember says /usr/local/bin/ember. Now it is important to understand the PATH.
Your PATH includes multiple directories and whenever you enter a commend it will be looked up in all theese directories. Now your PATH definitly contains /usr/local/bin/ and maybe later /Users/<my-username>/node_modules/.bin. It definitly should contain borth directories. If it does not contain /Users/<my-username>/node_modules/.bin thats something you should fix immediatly.
Now however your primary problem is that you basically installed ember-cli twice in two versions with two versions of npm. At the time you've installed ember originally you didnt use nvm yet. And using npm with nvm is in some ways significantly different from using it without it.
If you're using nvm basically everything lives in your $HOME (so /Users/<username>). Also the folder where npm install -g will install binaries into, it will be /Users/<my-username>/node_modules/.bin. This is actually a good thing because this means every user can install its own things there without sudo. On the other hand if you use the global npm you will install binaries installed with npm install -g into /usr/local/bin/. This however either requires sudo or changing some permissions. We dont know what you did back then, maybe you tried it once with sudo, and since then this one version basically overwrites all other versions you may install later with nvm because /usr/local/bin/ comes in your PATH before /Users/<my-username>/node_modules/.bin.
Now what you should do is get rid of /usr/local/bin/ember first. For this you do ls -lisa /usr/local/bin/ember because this is probably a symbolic link to somewhere else. Then you check where this link leads to and remove ember-cli from there. It is probably safe to just rm -rf the packages installed there. Next you delete the symbolic link /usr/local/bin/ember itself. Then run which ember again. Not this should either either fail or point to a different path. If it points to a different path you can verify that it is the version you want (in /Users/<my-username>/node_modules/.bin). If it fails you should verify that /Users/<my-username>/node_modules/.bin is actually in your PATH and that ember exists in /Users/<my-username>/node_modules/.bin.
Besides that I want to mention that ember-cli also has some interesting detail: if you run ember-cli inside an ember project it will search for the ember-cli installed inside this project and start it. So the global installed ember-cli version actually doesnt matter that much. It is basically only relevant for ember new. However for ember new you maybe want to consider to use npx because then you will always run the current version. So you could do npx ember-cli new my-app.

npm install can't find file (intermittently) in vagrant running on osx

I'm running npm in an ubuntu vagrant box. When running npm install or installing webpack or webpack-cli or babel core I keep running into the error
npm ERR! enoent ENOENT: no such file or directory, open '/var/www/html/app/client/node_modules/loader-utils/node_modules/minimist/package.json.3207661308'
npm ERR! enoent This is related to npm not being able to find a file.
babel core has previously installed in this same setup, but almost every time I run npm install it fails.
I suspect this is todo with file sharing between vagrant and osx or permissions issues. But this setup is the same as another (none nodejs) setup which works flawlessly.
I'm running the latest node 10 and the latest ubuntu/xenial64.
I never found an answer to this. But found a work around by using yum instead of npm. I would recommend using yum over npm in all situations now.

I can't install npm packages in my Ionic project folder and get error hints: No repository field. No license field. How to fix it?

Whatever npm package I try to install, I got such error hints:
"D:\Program Files\nodejs\node.exe" "D:\Program Files\nodejs\node_modules\npm\bin\npm-cli.js" install ionic
Standard error:
npm WARN my-project-name#1.1.1 No repository field.
npm WARN my-project-name#1.1.1 No license field.
npm ERR! Cannot read property '0' of undefined
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\my-user-name\AppData\Roaming\npm-cache\_logs\2017-08-28T03_14_36_746Z-debug.log
Process finished with exit code 1
I'm not familiar with npm and node.js, and I don't understand what the error hints mean.
The error log that it mentioned is a huge file with thousands of lines, which is even harder for me to understand. But basically I found the same error hints as the above at the bottom part of the log file.
I can install packages in the node.js folder with npm directive normally. But I just can't install them in my project (Ionic v1) folder, always getting the above three hints: No repository field. & No license field. & Cannot read property '0' of undefined.
I installed the latest version of Ionic (3.9.2) in the node.js folder. But because my project was developed with Ionic v1, so I installed version 1.3.3 of Ionic in my project folder. Is it relevant to the error hints that I got?
And I can't downgrade npm successfully by running npm install -g npm#4.2.0 command, getting such error hints:
D:\Program Files\nodejs\node_modules>npm install -g npm#4.2.0
npm ERR! path D:\Program Files\nodejs\npm.cmd
npm ERR! code EEXIST
npm ERR! Refusing to delete D:\Program Files\nodejs\npm.cmd: is outside D:\Program Files\nodejs\node_modules\npm and not a link
npm ERR! File exists: D:\Program Files\nodejs\npm.cmd
npm ERR! Move it away, and try again.
Try downgrading NPM
with npm install -g npm#4.2.0
Can you give bit more details: NPM version, on which folder you are running the install command and is your project connected with Git?
You can also try npm init in project directory to initialize repository and license etc if you want to [they are optional]
To downgrade NPM in windows, you need to start the command prompt with Administrator privileges.
Right click on command prompt shortcut and choose Run as Administrator.
You can also set the properties of the shortcut to always Run as Administrator:
Right click -> properties -> Shortcut tab -> Advanced -> click Run as administrator checkbox
Installing NPM as a different version now works
npm install -g npm#4
Note: If your NPM folder/install is missing, you will have re-install node.js to re-install NPM .

Resources