preactjs / preact-cli

😺 Your next Preact PWA starts in 30 seconds.
MIT License
4.69k stars 375 forks source link

Getting a command not found after global install on @2.1.1 #487

Closed thomasfaller closed 6 years ago

thomasfaller commented 6 years ago

What is the current behaviour?

After global installing I get a command not found. My code is as follows:

$ npm install -g preact-cli@latest
npm WARN deprecated gulp-util@3.0.8: gulp-util is deprecated - replace it, following the guidelines at https://medium.com/gulpjs/gulp-util-ca3b1f9f9ac5
/Users/tfaller/.npm-packages/bin/preact -> /Users/tfaller/.npm-packages/lib/node_modules/preact-cli/lib/index.js

> preact-cli@2.1.1 postinstall /Users/tfaller/.npm-packages/lib/node_modules/preact-cli
> node -p 'require("./check.js")()'

true
+ preact-cli@2.1.1
updated 1 package in 27.095s
$ preact create widget MDEditor
-bash: preact: command not found
$

I tried both preact-cli and preact-cli@latest but I get the same message Any thoughts?

If the current behaviour is a bug, please provide the steps to reproduce.

Please mention other relevant information.

thomasfaller commented 6 years ago

I'm not seeing an open issue on this so I'm assuming it might be something on my end with my _PATH or something. I've had issues with Home-brew in the past but it was working ok after I removed it. Any help would still be vastly appreciated 😅

ForsakenHarmony commented 6 years ago

Yeah, seems like an issue with your path is /Users/tfaller/.npm-packages and or /Users/tfaller/.npm-packages/lib in there? not entirely sure how you have npm set up

thomasfaller commented 6 years ago

Yeah, that's what I thought thanks @ForsakenHarmony I tried pulling out the global path and it gave ne this:

$ npm config get prefix
/Users/tfaller/.npm-packages
$

Does that seems right? So the CLI is being installed in the lib sub-folder instead of on the main path?

ForsakenHarmony commented 6 years ago

you can check where the executable is located (for me it's in the npm folder, which contains node_modules) and then see if that folder is in your path

I'm not sure about the lib sub-folder, it doesn't happen on windows, but might on mac

thomasfaller commented 6 years ago

Thanks.

I added a new directory in my PATH using

export PATH=$PATH:~/.npm-packages/bin

And it seems to be working now, hope this was a good fix 👍

GabeConsalter commented 5 years ago

Thanks.

I added a new directory in my PATH using

export PATH=$PATH:~/.npm-packages/bin

And it seems to be working now, hope this was a good fix 👍

I used this command with npm-global folder and works fine. If anyone has this folder too, can use.

Thanks!

jsarge11 commented 5 years ago

Thanks.

I added a new directory in my PATH using

export PATH=$PATH:~/.npm-packages/bin

And it seems to be working now, hope this was a good fix 👍

Sorry if commenting after it's closed isn't allowed - but where would you place this command? Is it on a file or do you run it in Terminal?

GabeConsalter commented 5 years ago

Hi @jsarge11. Run it on terminal. This command writes on bash file a PATH for bin folder of npm.

dartess commented 5 years ago

export PATH=$PATH:~/.npm-global/bin works for me.

sarangk-hotstar commented 2 years ago

with yarn, export PATH=$PATH:~/.yarn/bin worked for me!

rschristian commented 2 years ago

@sarangk-hotstar We don't recommend that you globally install Preact-CLI anymore so you shouldn't be running into this.