I am on OS X(El Capitan). I install node using following command.
brew install node
Then I installed webpack using following command:
npm install -g webpack
And I also followed this url : Github Url
To install globally but when I am running
webpack on my terminal I am getting
zsh: command not found: webpack
~/projects/personal/React npm install -g webpack
/Users/rahul/.npm-packages/bin/webpack -> /Users/rahul/.npm-packages/lib/node_modules/webpack/bin/webpack.js
> fsevents#1.0.14 install /Users/rahul/.npm-packages/lib/node_modules/webpack/node_modules/fsevents
> node-pre-gyp install --fallback-to-build
[fsevents] Success: "/Users/rahul/.npm-packages/lib/node_modules/webpack/node_modules/fsevents/lib/binding/Release/node-v48-darwin-x64/fse.node" is installed via remote
/Users/rahul/.npm-packages/lib
export
Apple_PubSub_Socket_Render=/private/tmp/com.apple.launchd.Tp9FugZTE3/Render
DISPLAY=/private/tmp/com.apple.launchd.ZgQngbBnwx/org.macosforge.xquartz:0
EDITOR='subl -w'
HOME=/Users/rahul
ITERM_PROFILE=Custom
ITERM_SESSION_ID=w0t4p1:4DEA1B55-94CE-48E7-85A6-347D29A53122
ITERM_SHELL_INTEGRATION_INSTALLED=Yes
LC_CTYPE=UTF-8
LESS=-R
LOGNAME=rahul
LSCOLORS=Gxfxcxdxbxegedabagacad
PAGER=less
PATH=/usr/local/share/python:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin
PROJECT_HOME=/Users/rahul/Projects
PWD=/Users/rahul/projects/personal/React
SHELL=/bin/zsh
SSH_AUTH_SOCK=/private/tmp/com.apple.launchd.Ixik08zS9V/Listeners
TERM=xterm-256color
TERM_PROGRAM=iTerm.app
TERM_PROGRAM_VERSION=3.0.7
TERM_SESSION_ID=w0t4p1:4DEA1B55-94CE-48E7-85A6-347D29A53122
TMPDIR=/var/folders/kk/9jwxx0r532s_cff8m4rx080w0000gn/T/
USER=rahul
USER_NAME=Rahul
VIRTUALENVWRAPPER_HOOK_DIR=/Users/rahul/.virtualenvs
VIRTUALENVWRAPPER_PROJECT_FILENAME=.project
VIRTUALENVWRAPPER_SCRIPT=/usr/local/bin/virtualenvwrapper.sh
VIRTUALENVWRAPPER_WORKON_CD=1
WORKON_HOME=/Users/rahul/.virtualenvs
XPC_FLAGS=0x0
XPC_SERVICE_NAME=0
ZSH=/Users/rahul/.oh-my-zsh
__CF_USER_TEXT_ENCODING=0x1F5:0x0:0x0
you need to install webpack locally into your project as well.
npm install webpack --save-dev
Related
When trying to create a new create react app project I get the following:
> npx create-react-app my-app
node:internal/modules/cjs/loader:1042
throw err;
Error: Cannot find module 'has-flag'
Does my setup look right?
> which node
/Users/grant/.nvm/versions/node/v18.13.0/bin/node
> $echo $PATH
zsh: no such file or directory: /Users/grant/.nvm/versions/node/v18.13.0/bin:/usr/local/bin:/System/Cryptexes/App/usr/bin:/usr/bin:/bin:/usr/sbin:/sbin:/Library/Apple/usr/bin
> whereis npm
npm: /Users/grant/.nvm/versions/node/v18.13.0/bin/npm
> npm config get prefix
/usr/local
> yarn global list
yarn global v1.22.19
info "create-next-app#13.1.6" has binaries:
- create-next-app
✨ Done in 2.30s.
> yarn global bin
/usr/local/bin
Node v18.13.0
npm v9.4.0
It seems like the issue is with the has-flag module, which is a required dependency for create-react-app. Try uninstalling and reinstalling the has-flag module with the following command:
npm install has-flag#latest
After that, try creating the new React app again with the following command:
npx create-react-app my-app
If it still doesn't work, you can try the following command:
npm install create-react-app -g
Then create a new React app with the following command:
npx create-react-app my-app
I'm trying to minify a whole folder of css files using minify-all.
But when I run: minify-all, I get:
Air-di-Giacomo:css jack$ sudo minify-all .
found file: alpha.css
/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104
throw new Error(bin + ' not found !');
^
Error: uglifyjs not found !
at getPath (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:104:17)
at Object.minify.fn.compress (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:132:27)
at Object.minify (/usr/local/lib/node_modules/minify-all/node_modules/node-minify/lib/node-minify.js:83:10)
at /usr/local/lib/node_modules/minify-all/index.js:30:13
at /usr/local/lib/node_modules/minify-all/index.js:14:13
at Array.forEach (native)
at walk (/usr/local/lib/node_modules/minify-all/index.js:10:36)
at minifyAll (/usr/local/lib/node_modules/minify-all/index.js:25:5)
at Object.<anonymous> (/usr/local/lib/node_modules/minify-all/index.js:45:5)
at Module._compile (module.js:409:26)
I already tried the following commands:
sudo npm install -g uglifyjs
and also to reinstall it in the correct order (never know):
sudo npm remove -g minify-all
sudo npm remove -g uglifyjs
sudo npm install -g uglifyjs
sudo npm install -g minify-all
and finally, in despair, I did:
cd /usr/local/lib/node_modules/minify-all/
sudo npm install uglifyjs
But I still get that error!
This seems to me a node dependency problem, and maybe for some of you it is a stupid problem, do you know how can I solve this?
Thanks in advance.
Found a solution by install it locally.
cd /../myCssFolder/
npm init
...
npm install uglifyjs
npm install minify-all
minify-all .
of course I prefer to have it globally so I can skip the npm project installation everytime... Any suggestions?
Global modules always install in NODE_PATH/bin。
why not print echo $path in terminal, Is there NODE_PATH/bin in it ?
if not, you can update ~/.bashrc(if you use bash) or ~/.zshrc(if you use zsh)
export PATH="OLD_PATH:NODE_PATH/bin"
The OLD_PATH is the older one.
I just installed bower via npm install bower --save-dev because I want to have this available for everybody who checks the branch out and runs "npm update". I knew how to execute bower if I installed it with npm install bower -g but how do I actually execute it now?
this way does not satisfy me:
./node_modules/bower/bin/bower -v
Isn't there something like npm tools bower -v?
No, there is no npm tools command. But here is an alternative solution.
If your shell is bash, you can add function into your .bashrc.
# ~/.bashrc
function npm-tools {
(PATH=$(npm bin):$PATH; eval $#;)
}
Then you can run command like following to achieve what you want.
# $ tree node_modules/ -L=1
# node_modules/
# └── bower
$ ./node_modules/bower/bin/bower -v
1.7.9
$ npm-tools bower -v
1.7.9
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
Yeoman and bower do not work at all. I installed node using the Mac node package downloaded from the nodejs site.
npm: 1.4.21 / node: v0.10.30
.bash_profile:
export PATH=$HOME/local/bin:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin
export M2_HOME=/Users/cmorrow/apache-maven-3.1.1
export PATH=$PATH:$M2_HOME/bin
export JAVA_HOME=/Library/Java/Home
[[ -s "$HOME/.rvm/scripts/rvm" ]] && source "$HOME/.rvm/scripts/rvm" # Load RVM into a shell session *as a function*
export PATH=/usr/local/bin:$PATH
export PATH=/Users/cmorrow/npm/lib/node_modules:$PATH
I installed yo with:
npm install -g yo
The post install reads:
yo#1.2.1 postinstall /Users/cmorrow/npm/lib/node_modules/yo
node ./scripts/doctor
[Yeoman Doctor] Everything looks alright!
If you install nodejs by HomeBrew he manually create a symbolic link in the folder
/usr/local/bin
if the manually installation don't generate that symbolic link you can doing manually with this command (with sudo):
ln -s /Users/cmorrow/npm/lib/node_modules/yo/cli.js /usr/local/bin/yo
chmod +x /usr/local/bin/yo
Not sure the exact fix, but I made a few changes and everything now works.
Things I did were:
Upgraded node js to v0.10.31
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
Reinstalled yeoman
sudo npm install -g yo