Installation issue with Ionic - node.js

when I try to install ionic via npm I get the following issue. The installation just stops when trying to install the node-sass package. This is what I get from the command line:
npm info install node-sass#3.4.1
> node-sass#3.4.1 install /usr/local/lib/node_modules/ionic/node_modules/ionic-app-lib/node_modules/node-sass
> node scripts/install.js
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
The installation process just stops at this point. During installation, I've used the loglevel option to track the logs. Any ideas about what can be the cause of this error? Thanks Sandro

Hope this will help you.
if the last line of your cmd shows :
/usr/local/bin/cordova -> /usr/local/lib/node_modules/cordova/bin/cordova
then its permission issue.
sudo chown -R *username*/usr/local/lib/node_modules/cordova/
if there is any issues with node-saas
It's trying to force node-sass#3.4.1
You Can Try using npm install node-sass to get the latest version(3.4.2).
OR
When i got problems with node-saas , friend on github helped me with using libsass commands:
$ sudo rm -rf node_modules/ && cat package.json | sed -i.bak 's/"gulp-sass": "^X.X.X"/"gulp-sass": "^3.4.1"/g' package.json && npm install && ionic lib update
Where X is the version of gulp-sass in your package.json
Remove the old files in node_modules. I'm not sure is necessary to use 'sudo'
$ sudo rm -rf node_modules/
Search and replace inside package.json updating gulp-sass version to ^3.4.1. It also creates a backup (package.json.bak),
$ cat package.json | sed -i.bak 's/"gulp-sass": "^X.X.X"/"gulp-sass": "^3.4.1"/g' package.json
Reinstall dependencies
$ npm install
Update the ionic lib in the project
ionic lib update

Related

npm command not found error but node is installed

I installed node and npm with Homebrew a while ago, they both worked fine until today when I keep running into the npm command not found error.
When is run $ whereis node, I get nothing back
When I do $ which node, I see /usr/local/bin/node
When I do $ node -v, I see v4.4.7
When I do $ whereis npm, I get nothing back
When I do $ which npm, I get nothing back
When I do $ npm -v, I see -bash: npm: command not found
I have tried
$ brew update
$ brew uninstall npm
$ brew install npm
I have also made sure that my $NODE_PATH environment variable is set:
# In ~/.bash_profile file:
export NODE_PATH="/usr/local/lib/node_modules"
I also followed these instructions from https://himanen.info/solved-npm-command-not-found/
Nothing seems to work and I keep getting npm: command not found when I run any command in any folder with npm. Any ideas? Thanks
I had the same issue, I am using a MAC.
It was a permission issue in my case, here is what I already did:
$ brew update
$ brew uninstall npm
$ brew install npm
That didn't work for me, so I tried this:
$ sudo chmod -R 777 /usr/local/lib
$ brew postinstall node
and this linked installed node with npm, when I typed:
$ npm -v
5.3.0
Now all commands followed by NPM are working fine,
like npm install
Hope this will work for all!!
Figured out the issue. So the root of the problem was that I installed npm using Homebrew and there are some issues with what goes on under the hood with Homebrew and npm.
To fix this I did the following:
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node --without-npm
echo prefix=~/.npm-packages >> ~/.npmrc
curl -L https://www.npmjs.com/install.sh | sh
Important!
Do this in .bash_profile
export PATH="$HOME/.npm-packages/bin:$PATH"
export PATH="$HOME/.node/bin:$PATH"
Now everything works like a charm
In mac via homebrew, when you are getting error like
Error: Permission denied # dir_s_mkdir - /usr/local/lib/node_modules/npm
or mostly getting several folder permission, don't give full permission like
$ sudo chmod -R 777 /usr/local/lib
Please use as mentioned below
$ sudo chown -R $(whoami):admin /usr/local/lib/node_modules/
What it will do, simply gives the ownership to the user (linux users also can use this).
Hint: And in mac please use homebrew for installation. Advantages of homebrew you can switch between versions, easy to uninstall, you no need to run as root (sudo), like wise lots of advantages are there, as a developer its recommended to use homebrew (https://brew.sh/). And one more thing whenever you are getting some error like permission denied or something don't, give the full permission instead of using chmod use chown.
I had the same issue, I executed following command to install node and npm - it worked perfectly.
rm -rf /usr/local/lib/node_modules
brew uninstall node
brew install node

Error: EACCES when creating new Ember project

I just installed Linux Mint (version 17.2) and I'm trying to install Ember. Everything seemed to go fine, but I'm getting this error when I run ember new testProject.
create vendor/.gitkeep
EACCES, mkdir '/home/mkm/.npm/mkdirp/0.4.2'
Error: EACCES, mkdir '/home/mkm/.npm/mkdirp/0.4.2'
at Error (native)
Per a recommendation in the Ember Documentation I used this guide to install Node.js and NPM. Some of what I've read suggest the issue is nodejs was installed with sudo, but apt-get failed when I didn't use sudo.
I attempted to run the new project anyway. bower install completed successfully. But ember serve failed with Cannot find module 'chalk'.
--Version Info
$ ember --version
version: 1.13.8
Could not find watchman, falling back to NodeWatcher for file system events.
Visit http://www.ember-cli.com/user-guide/#watchman for more info.
node: 0.12.7
npm: 2.13.4
os: linux x64
The only command that was needed to run with sudo for me was:
npm install
I suggest you delete node_modules/ in your project directory completely, then run:
sudo npm install
You can also add option --verbose to see if everything is correctly installing and installation isn't stuck.
You could also change permissions for .npm directory to avoid some problems like that in future:
sudo chmod 777 -R /home/mkm/.npm
You can use following commands to install and use npm without sudo:
wget -qO- https://raw.githubusercontent.com/creationix/nvm/v0.25.4/install.sh | NVM_DIR="/home/your-user-name/.nvm" bash
export NVM_DIR="/home/your-user-name/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && . "$NVM_DIR/nvm.sh"
nvm install 0.12
nvm alias default 0.12
npm install -g ember-cli
npm install -g bower
npm install -g phantomjs
Here is a link to nvm repository with latest version and documentation: https://github.com/creationix/nvm

npm upgrade with homebrew

When node (v.0.10.33) is installed with homebrew (v. 0.9.5), at one point it says:
==> Caveats
If you update npm itself do NOT use the npm upgrade command
Instead execute:
npm install -g npm#latest
So, what exactly is npm upgrade and what is the difference with npm install -g npm#latest?
-- edit 2015
the problem doesn't exist anymore with the current version of node. (but I never had an answer to what npm upgrade is?)
Use npm install to install a package and npm update to update a package.
That Homebrew npm caveat was removed after the issue with npm update -g was fixed.
npm comes bundled with node, both part of Node.js install --- no need to install separately
Below are the steps to install Node.js from source (OSX/linux)
Issue cmds as yourself NOT root (sudo)
to start fresh remove prior node and npm installs as well as these :
sudo mv ~/.npmrc ~/.npmrc_ignore
sudo mv ~/.npm ~/.npm_ignore
sudo mv ~/tmp ~/tmp_ignore
sudo mv ~/.npm-init.js ~/.npm-init.js_ignore
download source from : http://nodejs.org/download/
cd freshly-downloaded-dir
define environment variable NODE_PATH as the dir for subsequent module installs
export NODE_PARENT=${HOME}/nodejs-v0.10.33
export PATH=${NODE_PARENT}/bin:${PATH}
export NODE_PATH=${NODE_PARENT}/lib/node_modules
./configure --prefix=${NODE_PARENT}
make
make install # IMPORTANT this is NOT using sudo
# not wanted since installing into $USER owned $NODE_PARENT
which puts it into dir defined by above --prefix
when you use syntax : npm install -g some_cool_module
the -g for global installs it into dir $NODE_PATH and not your $PWD
Now put above three export xxx=yyy
commands into your ~/.bashrc or some such to persist these environment variable changes

How do I know whether I have Node.js and npm successfully installed on Ubuntu 14.04?

I installed Node.js with these instructions and it seemed successful:
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs
Then I installed npm with these instructions:
sudo curl https://www.npmjs.org/install.sh | sh
The nodejs installation seemed to work without errors but the npm command gave me a lot of errors. But it seems like they are installed because when I test what version I have they both come up:
nodejs -v
v0.10.30
npm -v
1.4.21
So If this doesn't tell me that I have both programs successfully installed, which I assume I do not, how do I know?
I think your tests tell that both or properly installed.
But you can try just type node in terminal & it should open a node shell, where you can check by running basic commands.
Current distributions of node.js (including the one you downloaded) already include npm. So maybe installing npm manually is one source of your errors. Beware that usually you run "npm install" with the permissions of a regular user. There are only some npm-based utilities that are to be installed with root permissions and the '-g' (global) command line switch.
On linux if you wish to install node.js and npm as yourself NOT root :
to start fresh remove prior node.js and npm installs as well as these :
~/.npmrc
~/.npm
~/tmp
~/.npm-init.js
create your ~/bin/ directory if not already created :
mkdir ${HOME}/bin
download source from : http://nodejs.org/download/
cd node-v0.10.30/
./configure --prefix=${HOME}/bin/nodejs
make -j8
make install
which puts it into dir defined by above --prefix
export PATH=${HOME}/bin/nodejs/bin:$PATH
define NODE_PATH so node can find dir for modules otherwise
npm install xxx will put newly installed module into dir in curr dir :
export NODE_PATH=${HOME}/bin/nodejs/lib/node_modules
do above AND use syntax :
npm install xxxxx -g
always use the -g for global which puts package xxxxx into $NODE_PATH
NOTE - nodejs install gives you npm as well :
ls -la ${HOME}/bin/nodejs/bin

How to clean node_modules folder of packages that are not in package.json?

Assume I install project packages with npm install that looks into package.json for modules to be installed. After a while I see that I don't need some specific module and remove its dependency from package.json. Then I remove some other modules from package.json because they are not needed anymore and others are replaced with alternatives.
Now I want to clean node_modules folder so that only modules listed in package.json stay there and the rest must go, something like npm clean. I know I can remove them manually but would like to have some nice ready to use sugar functionality for that.
I think you're looking for npm prune
npm prune [<name> [<name ...]]
This command removes "extraneous" packages. If a package name is
provided, then only packages matching one of the supplied names are
removed.
Extraneous packages are packages that are not listed on the
parent package's dependencies list.
See the docs: https://docs.npmjs.com/cli/prune
You could remove your node_modules/ folder and then reinstall the dependencies from package.json.
rm -rf node_modules/
npm install
This would erase all installed packages in the current folder and only install the dependencies from package.json. If the dependencies have been previously installed npm will try to use the cached version, avoiding downloading the dependency a second time.
Due to its folder nesting Windows can’t delete the folder as its name is too long. To solve this, install RimRaf:
npm install rimraf -g
rimraf node_modules
From version 6.5.0 npm supports the command clean-install (ci) to hard refresh all the packages.
Please, see the references:
npm 6.x: npm-ci | npm Docs.
npm 7.x: npm-ci | npm Docs.
npm Blog Archive: Introducing npm ci for faster, more reliable builds.
simple just run
rm -r node_modules
in fact, you can delete any folder with this.
like rm -r AnyFolderWhichIsNotDeletableFromShiftDeleteOrDelete.
just open the gitbash move to root of the folder and run this command
Hope this will help.
First globally install rimraf
npm install rimraf -g
go to the path using cmd where your node_modules folder and apply below command
rimraf node_modules
Just in-case somebody needs it, here's something I've done recently to resolve this:
npm ci - If you want to clean everything and install all packages from scratch:
-It does a clean install: if the node_modules folder exists, npm deletes it and installs a fresh one.
-It checks for consistency: if package-lock.json doesn’t exist or if it doesn’t match the contents of package.json, npm stops with an error.
https://docs.npmjs.com/cli/v6/commands/npm-ci
npm-dedupe - If you want to clean-up the current node_modules directory without deleting and re-installing all the packages
Searches the local package tree and attempts to simplify the overall structure by moving dependencies further up the tree, where they can be more effectively shared by multiple dependent packages.
https://docs.npmjs.com/cli/v6/commands/npm-dedupe
Have you tried npm prune?
it should uninstall everything not listed in your package file
https://npmjs.org/doc/cli/npm-prune.html
The best article I found about it is this one: https://trilon.io/blog/how-to-delete-all-nodemodules-recursively
All from the console and easy to execute from any folder point.
But as a summary of the article, this command to find the size for each node_module folder found in different projects.
find . -name "node_modules" -type d -prune -print | xargs du -chs
And to actually remove them:
find . -name 'node_modules' -type d -prune -print -exec rm -rf '{}' \;
The article contains also instructions for windows shell.
I have added few lines inside package.json:
"scripts": {
...
"clean": "rmdir /s /q node_modules",
"reinstall": "npm run clean && npm install",
"rebuild": "npm run clean && npm install && rmdir /s /q dist && npm run build --prod",
...
}
If you want to clean only you can use this rimraf node_modules or rm -rf node_modules.
It works fine
You can also use npx in combination with rimraf to remove all node modules with one command, so you don't have to install rimraf first.
So go to the path where your node_modules folder is located by using cmd (in case you are not there already) and run the following command
npx rimraf node_modules
For Windows User, alternative solution to remove such folder listed here: http://ask.osify.com/qa/567
Among them, a free tool: Long Path Fixer is good to try: http://corz.org/windows/software/accessories/Long-Path-Fixer-for-Windows.php
rimraf is an package for simulate linux command [rm -rf] in windows. which is useful for cross platform support. for install its CLI:
npm install rimraf -g
If you are using YARN in your project please add below line to your pacjage.json script and run yarn clean to execute on project terminal
"clean": "rm -rf yarn.lock node_modules ios/Podfile.lock && yarn install && cd ios && pod install && pod update && cd .."
Use following command instead of npm install
npm ci

Resources