Command not found - vagrant

I'm running into a problem with accessing Yeoman after installing it on a fresh Homestead installation. Everything seems fine during the install after npm install -g yo and yo doctor runs just fine and finds no problem during the installation. However, after I've installed yeoman, yo: command not found is the error message I'm getting on my VM.
vagrant#homestead:~$ npm install -g yo
npm WARN deprecated npmconf#2.1.2: this package has been reintegrated into npm and is now out of date with respect to npm
/home/vagrant/.node/bin/yo -> /home/vagrant/.node/lib/node_modules/yo/lib/cli.js
/home/vagrant/.node/bin/yo-complete -> /home/vagrant/.node/lib/node_modules/yo/lib/completion/index.js
> spawn-sync#1.0.15 postinstall /home/vagrant/.node/lib/node_modules/yo/node_modules/spawn-sync
> node postinstall
> yo#1.8.4 postinstall /home/vagrant/.node/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ Node.js version
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ npm version
✔ NODE_PATH matches the npm root
Everything looks all right!
/home/vagrant/.node/lib
└─┬ yo#1.8.4
├── async#1.5.2
├─┬ chalk#1.1.3
│ ├── ansi-styles#2.2.1
│ ├── escape-string-regexp#1.0.5
│ ├── has-ansi#2.0.0
│ ├── strip-ansi#3.0.1
│ └── supports-color#2.0.0
├── cli-list#0.1.8
[[REMOVED FOR READABILITY]]
└─┬ yosay#1.2.0
├── cli-boxes#1.0.0
├── pad-component#0.0.1
├─┬ taketalk#1.0.0
│ ├── get-stdin#4.0.1
│ └── minimist#1.2.0
└── wrap-ansi#2.0.0
vagrant#homestead:~$ yo
yo: command not found
My path in ~/.bashrc says the following: PATH=/usr/bin:/bin:/usr/sbin:/sbin:/usr/local/bin:/home/vagrant/.node/lib
Is there anything else that I'm missing here that might be causing this?

Add /home/vagrant/.node/bin to your path. :)

Related

Can't remove Gatsby NPM package on MacOS

I'm having some issues getting Gatsby working. I want to remove my previous installation and start fresh.
Running npm list -g --depth 0 reveals:
/usr/local/lib
├── gatsby-cli#2.12.68
├── grunt-cli#1.3.2
└── npm#6.4.1
When I run npm uninstall --save -g gatsby-cli#2.12.68 the output is up to date in 0.031s - yet the Gatsby NPM package is still there.
Is there something I'm doing wrong here? Any help would be appreciated :)

NativeScript 'Create' EACCES: permission denied on macOS

I'm new to Mac, to macOS development and to NativeScript.
I'm trying to start a new tns project using:
sudo tns create rsrpt --ng
and I get this error all the time:
Error: EACCES: permission denied, mkdir '/Users/myUser/code/rsrpt/hooks'
Out of frustration, after 10 hours, I ran the following commands:
sudo chown -R $(whoami) ~/.local
and even this: (I hope I didn't ruin permissions on this mac)
sudo chown -R $(whoami) ~/
But nothing helped. I still get the attached detailed error. Any help on how to overcome this permission problem would be appreciated! Thanks!
> nativescript-angular#6.1.0 postinstall /Users/myUser/code/rsrpt/node_modules/nativescript-angular
> node postinstall.js
fs.js:885
return binding.mkdir(pathModule._makeLong(path),
^
Error: EACCES: permission denied, mkdir '/Users/myUser/code/rsrpt/hooks'
at Object.fs.mkdirSync (fs.js:885:18)
at Object.<anonymous> (/Users/myUser/code/rsrpt/node_modules/nativescript-angular/postinstall.js:11:12)
at Module._compile (module.js:652:30)
at Object.Module._extensions..js (module.js:663:10)
at Module.load (module.js:565:32)
at tryModuleLoad (module.js:505:12)
at Function.Module._load (module.js:497:3)
at Function.Module.runMain (module.js:693:10)
at startup (bootstrap_node.js:191:16)
at bootstrap_node.js:612:3
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! nativescript-angular#6.1.0 postinstall: `node postinstall.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the nativescript-angular#6.1.0 postinstall script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/myUser/.npm/_logs/2018-08-14T00_22_47_432Z-debug.log
Command npm install failed with exit code 1
# tns create
┌───────────────┬────────────────────────────────────────────────────────────┐
│ Usage │ Synopsis │
│ Create from │ $ tns create <App Name> [--path <Directory>] [--appid <App │
│ default │ ID>] │
│ JavaScript │ │
│ template │ │
│ Create from │ $ tns create <App Name> --template typescript [--path │
│ default │ <Directory>] [--appid <App ID>] OR $ tns create <App Name> │
│ TypeScript │ --tsc [--path <Directory>] [--appid <App ID>] OR $ │
│ template │ tns create <App Name> --template tsc [--path <Directory>] │
│ │ [--appid <App ID>] │
│ Create from │ $ tns create <App Name> --template angular [--path │
│ default │ <Directory>] [--appid <App ID>] OR $ tns create <App Name> │
│ Angular │ --template ng [--path <Directory>] [--appid <App ID>] │
│ template │ OR $ tns create <App Name> --ng [--path <Directory>] [- │
│ │ -appid <App ID>] │
│ Copy from │ $ tns create <App Name> [--path <Directory>] [--appid <App │
│ existing │ ID>] │
│ project │ │
│ Create from │ $ tns create <App Name> [--path <Directory>] [--appid <App │
│ custom │ ID>] --template <Template> │
│ template │ │
└───────────────┴────────────────────────────────────────────────────────────┘
Creates a new project for native development with NativeScript.
### Options
* --path - Specifies the directory where you want to create the project, if different from the current directory. The directory must be empty.
* --appid - Sets the application identifier for your project.
* --template - Specifies a valid npm package which you want to use to create your project. If --template is not set, the NativeScript CLI creates the project from the default JavaScript hello-world template.
* --ng - Sets the template for your project to the Angular template.
* --tsc - Sets the template for your project to the TypeScript template.
### Attributes
* <App Name> is the name of project. The specified name must meet the requirements of all platforms that you want to target. For more information about the <App Name> requirements, run $ tns help create
* <App ID> is the application identifier for your project. It must be a domain name in reverse and must meet the requirements of all platforms that you want to target. If not specified, the application identifier is set to org.nativescript.<App name> For more information about the <App ID> requirements, run $ tns help create
Did you try “tns doctor”? I am not sure is it checking permissions or authority rules.
And did you try for another directory? Maybe you need to re-install complate(npm&nativescript)

bash: pm2: command not found

I can't run pm2 on ubuntu box.
I'm not sure what's the problem.
The pm2 is installed globally.
npm list -g --depth=0
/opt/nodejs/lib
├── forever#0.15.3
├── node-gyp#3.4.0
├── npm#2.15.9
├── pm2#2.1.5
├── userdown#0.2.1
└── wait-for-mongo#0.2.0
But I still get
pm2
-bash: pm2: command not found
if I run other app
userdown
Starting Script is not provided
versions
node v4.5.0
npm v2.15.9
log from installation:
sudo npm install pm2 -g
npm WARN optional dep failed, continuing fsevents#1.0.15
/opt/nodejs/bin/pm2 -> /opt/nodejs/lib/node_modules/pm2/bin/pm2
/opt/nodejs/bin/rundev -> /opt/nodejs/lib/node_modules/pm2/bin/rundev
/opt/nodejs/bin/pm2-dev -> /opt/nodejs/lib/node_modules/pm2/bin/pm2-dev
/opt/nodejs/bin/pm2-docker -> /opt/nodejs/lib/node_modules/pm2/bin/pm2-docker
pm2#2.1.5 /opt/nodejs/lib/node_modules/pm2
├── gkt#1.0.0
├── eventemitter2#1.0.5
├── semver#5.3.0
├── async#1.5.2
├── fclone#1.0.10
├── pidusage#1.1.0
├── vizion#0.2.13
├── commander#2.9.0 (graceful-readlink#1.0.1)
├── debug#2.3.0 (ms#0.7.2)
├── pm2-axon-rpc#0.4.5 (fclone#1.0.8)
├── pm2-deploy#0.3.3 (tv4#1.2.7)
├── pm2-multimeter#0.1.2 (charm#0.1.2)
├── chalk#1.1.3 (escape-string-regexp#1.0.5, ansi-styles#2.2.1, supports-color#2.0.0, strip-ansi#3.0.1, has-ansi#2.0.0)
├── cli-table#0.3.1 (colors#1.0.3)
├── mkdirp#0.5.1 (minimist#0.0.8)
├── source-map-support#0.4.6 (source-map#0.5.6)
├── nssocket#0.6.0 (eventemitter2#0.4.14, lazy#1.0.11)
├── pmx#0.6.8 (json-stringify-safe#5.0.1)
├── pm2-axon#3.0.2 (amp-message#0.1.2, escape-regexp#0.0.1, amp#0.3.1, debug#2.2.0)
├── cron#1.1.1 (moment-timezone#0.5.9)
├── yamljs#0.2.8 (glob#7.1.1, argparse#1.0.9)
├── chokidar#1.6.1 (path-is-absolute#1.0.1, async-each#1.0.1, inherits#2.0.3, glob-parent#2.0.0, is-glob#2.0.1, is-binary-path#1.0.1, readdirp#2.1.0, anymatch#1.3.0)
├── shelljs#0.7.5 (interpret#1.0.1, glob#7.1.1, rechoir#0.6.2)
└── moment#2.17.0
kamil#vps2:~$ pm2
-bash: pm2: command not found
ubuntu version:
uname -a
Linux vps2 2.6.32-042stab111.11 #1 SMP Tue Sep 1 18:19:12 MSK 2015 x86_64 x86_64 x86_64 GNU/Linux
Ok got answer myself.
I check what happens for
whereis pm2
pm2: /opt/nodejs/bin/pm2
then I checked
whereis userdown
userdown: /usr/bin/userdown /usr/bin/X11/userdown /opt/nodejs/bin/userdown
hmm in /usr/bin....
So I did
sudo ln -s /opt/nodejs/bin/pm2 /usr/bin/pm2
and it works :)
The problem is that you are running NPM as sudo, so you will only be able to access it using:
sudo pm2 start server.js
Install without sudo, you may even install without the -gflag and call it directly from node_modules directory. This may be useful if you do not have root (admin) privileges in the machine you're working on.
npm install pm2
./node_modules/.bin/pm2 start server.js
Follow the proper nodejs isntallation, npm permission fixes and npm global packages tweaks:
# https://gist.github.com/servercharlie/9a7e0d0e1645b4c6fbfe5de566fcf1ca
Your script needs to do some thing that requires root privilege? (ie: you're getting an error on using port 80)
[wrong] - trying to run w/ sudo
[correct] - login as root "sudo su" then do pm2 start app.js --name "whatever" --watch
that does it, no need to configure any bashrc or profile files.
extra: worried about your app doing crazy shit? (ie, since it's executed as root, the script can use nodejs's exec and do some crazy stuff.)
hence. do this: do the root-stuff first with your script, then lower your privilege after some timeout:
// i use port 80 first.. at this point the script's uid is ROOT.
app.listen(80);
// after 2 seconds we switch to uid AZUREUSER, which obviously isn't root anymore.
setTimeout(function(){
process.setuid("azureuser");
}, 2000);
In my scenario I wrote a shell script that was triggered by jenkins build and
I fixed using following link
https://github.com/Unitech/pm2-deploy/issues/41

Nativescript not livesyncing

I recently updated all my tns deps:
karlis#karlis-SATELLITE-L750 ~/Projects/my-instagram/test $ tns info
All NativeScript components versions information
┌──────────────────┬─────────────────┬────────────────┬─────────────┐
│ Component │ Current version │ Latest version │ Information │
│ nativescript │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-core-modules │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-android │ 2.3.0 │ 2.3.0 │ Up to date │
│ tns-ios │ 2.3.0 │ 2.3.0 │ Up to date │
When i change something in code and save, this shows up in console. However nothing changes in the app( closing and opening the app doesn't help too ):
4:42:18 PM - File change detected. Starting incremental compilation...
4:42:22 PM - Compilation complete. Watching for file changes.
Executing before-prepare hook from /home/karlis/Projects/my-instagram/test/hooks/before-prepare/nativescript-dev-typescript.js
Project successfully prepared (android)
Transferring project files...
Successfully transferred all files.
Applying changes...
Successfully synced application org.nativescript.test on device 3d828389.
Each time i run the command tns livesync android --watch --device=3d828389 i get the full app reinstall and message showing: The application with id "org.nativescript.test" is not installed on device with identifier 3d828389. However the app IS installed on the phone.
Discuss.
The problem was in my app/App_Resources/android/Manifest and gradle.
I changed them to original ones and it worked.

React Native init does not create Xcode project

When I run react-native init application-name, no XCode project gets generated.
The node_modules dir and package.json file is generated and npm install is run, but immediately after the 'npm dependency graph' is printed, it stops.
The last line of output is rbenv: no such commandexec'`, which seems rather strange as this has nothing to do with rbenv/Ruby.
Full log output:
👉 react-native init ReactiveNews
This will walk you through creating a new React Native project in /Users/taylor/Git/ReactiveNews
npm WARN engine makeerror#1.0.10: wanted: {"node":"0.6.x"} (current: {"node":"0.10.38","npm":"1.4.28"})
> ws#0.4.31 install /Users/taylor/Git/ReactiveNews/node_modules/react-native/node_modules/ws
> (node-gyp rebuild 2> builderror.log) || (exit 0)
CXX(target) Release/obj.target/bufferutil/src/bufferutil.o
SOLINK_MODULE(target) Release/bufferutil.node
SOLINK_MODULE(target) Release/bufferutil.node: Finished
CXX(target) Release/obj.target/validation/src/validation.o
SOLINK_MODULE(target) Release/validation.node
SOLINK_MODULE(target) Release/validation.node: Finished
npm WARN engine tmpl#1.0.3: wanted: {"node":"0.6.x"} (current: {"node":"0.10.38","npm":"1.4.28"})
react-native#0.2.1 node_modules/react-native
├── absolute-path#0.0.0
├── stacktrace-parser#0.1.1
├── react-timer-mixin#0.13.1
├── underscore#1.7.0
├── q#1.0.1
├── yargs#1.3.2
├── debug#2.1.3 (ms#0.7.0)
├── source-map#0.1.31 (amdefine#0.1.0)
├── optimist#0.6.1 (wordwrap#0.0.2, minimist#0.0.10)
├── worker-farm#1.1.0 (xtend#4.0.0, errno#0.1.2)
├── rebound#0.0.12
├── sane#1.0.1 (watch#0.10.0, fb-watchman#0.0.0, minimatch#0.2.14, walker#1.0.6)
├── uglify-js#2.4.17 (uglify-to-browserify#1.0.2, async#0.2.10, yargs#1.3.3, source-map#0.1.34)
├── jstransform#10.0.1 (base62#0.1.1, esprima-fb#13001.1.0-dev-harmony-fb)
├── joi#5.1.0 (topo#1.0.2, isemail#1.1.1, hoek#2.12.0, moment#2.9.0)
├── connect#2.8.3 (uid2#0.0.2, methods#0.0.1, fresh#0.1.0, pause#0.0.1, cookie-signature#1.0.1, buffer-crc32#0.2.1, qs#0.6.5, bytes#0.2.0, cookie#0.1.0, formidable#1.0.14, send#0.1.2)
├── module-deps#3.5.6 (inherits#2.0.1, shallow-copy#0.0.1, minimist#0.2.0, subarg#0.0.1, stream-combiner2#1.0.2, parents#1.0.1, readable-stream#1.0.33, resolve#0.7.4, through2#0.4.2, duplexer2#0.0.2, concat-stream#1.4.7, browser-resolve#1.8.1, JSONStream#0.7.4, detective#3.1.0)
├── react-tools#0.13.0-rc2 (commoner#0.10.1)
└── ws#0.4.31 (tinycolor#0.0.1, options#0.0.6, commander#0.6.1, nan#0.3.2)
rbenv: no such command `exec'
The issue was with the init.sh script under node_modules/react-native, rbenv threw the rbenv: no such command `exec' every time it was executed. I first solved it by running it directly through rbenv with rbenv exec but was able to solve the issue entirely by turning the rbenv bundler plugin off and on again.

Resources