Why am I told to install versioned Expo CLI when it's already installed? - npm

When I run
expo-cli doctor
I get
WARNING: The legacy expo-cli does not support Node +17. Migrate to the versioned Expo CLI (npx expo).
But when I run
yarn expo doctor
I get
expo doctor is not supported in the local CLI, please use expo-cli doctor instead
This seems circular, or at least fishy. I have the latest expo and expo-cli installed, but I'm still being told to install something else (more recent).
How do I fix this so I'm not being told to install something that (I think) I already have installed.
Anywhere:
$ npm list --location=global --depth=0
/opt/homebrew/lib
├── #aws-amplify/cli#10.7.3
├── corepack#0.16.0
├── create-expo-app#1.3.2
├── eas-cli#3.6.0
├── expo-cli#6.3.1
├── firebase-tools#11.23.1
├── ios-sim#9.0.0
├── npm-check-updates#16.7.5
├── npm#9.5.0
└── react-devtools#4.27.2
$ which -a eas
/opt/homebrew/bin/eas
$ eas --version
eas-cli/3.6.0 darwin-arm64 node-v18.14.1
$ expo --version
WARNING: The legacy expo-cli does not support Node +17. Migrate to the versioned Expo CLI (npx expo).
6.3.1
In my project directory:
$ yarn list
...
├── expo-dev-client#2.0.1
├── expo-file-system#15.1.1
├── expo-sharing#11.0.1
├── expo-splash-screen#0.17.5
├── expo-status-bar#1.4.4
├── expo-updates#0.15.6
├── expo#47.0.13
$ which -a expo
/private/var/folders/90/46v8ldy13r13wf1hr7w9xzfw0000gn/T/xfs-08dd5804/expo
/opt/homebrew/bin/expo
$ /private/var/folders/90/46v8ldy13r13wf1hr7w9xzfw0000gn/T/xfs-08dd5804/expo
-bash: /private/var/folders/90/46v8ldy13r13wf1hr7w9xzfw0000gn/T/xfs-08dd5804/expo: No such file or directory
...
At ~:
$ npm list
/Users/Rax
└── (empty)
$ yarn list
yarn list v1.22.19
Done in 0.01s.
$ which -a expo
/opt/homebrew/bin/expo

You need to do exactly what error message states. Instead of running expo-cli you need to use npx expo, it will use locally installed(in your project) version of the expo cli that is tied to the version of expo package in your project.
Note that expo doctor is not implemented in local cli, so that command is always using global one.

Related

How to use npm workspace

I develop my app by using npm workspace.but I am totally novice to this concept so that I would like to understand npm workspace behavior
.
├── package.json
└── packages
├── a
│ └── package.json
├── b
│ └── package.json
└── c
└── package.json
package.json
{
"workspaces": [
"packages/*"
]
}
My question is
①what happens when I run npm install in root directory ?
All the packages are installed in each repository ? or root directory ?
②npm install in each project is not recommended ?
if someone has opinion, will you please let me know.
Thanks
So long as all packages have the same version of dependencies listed (e.g. thing#1.0.0), then npm install run from the root of your repository will add the dependency into the root node_modules directory.
If one of your packages (e.g. packages/c) has a different version of a dependency (e.g. thing#1.0.1) then that would appear in packages/2/node_modules)
In theory you are using npm workspaces to ensure some consistency across packages, therefore ensuring your versions are consistent will mean node_modules is only ever created in the root of your repository

Npm script to run both child directory folders?

How do I write a script in my Parent Folder's package.json file so that when I run npm install it installs the node modules in each folder and npm start will go to each folder and run npm start
The Frontend and Backend folder both use npm start to start up and I want to somehow do the same in the parent folder to simultaneously start both
This is the file structure:
ParentFolder
├── package.json . <--- npm install && npm start scripts
├── FrontEnd
│ ├── /node_modules
│ ├── package.json
│ └── index.js
├── Backend
│ ├── /node_modules
│ ├── package.json
│ ├── routes.js
│ └── server.js.js
Installing in two directories is easy with find
find ./*/* -maxdepth 1 -name package.json -execdir npm install \;
This looks in each directory for a package.json and executes npm install;
npm start becomes a bit harder. At least on Windows using Cygwin, I wanted to do:
npm --prefix ./FrontEnd start ./FrontEnd & npm --prefix ./Backend start ./Backend
But it wasn't actually running in the background like I expected and FrontEnd was the only one that actually started. Depending on your start script this could work for you.
Possible solutions for this could be concurrently or npm-run-all -p.

How to install exp globally through npm

After running npm install -g exp in my cmd running in administrator mode successfully, I am unable to get exp --version or any other command with exp receiving
'exp' is not recognized as an internal or external command,
operable program or batch file
please tell me how I can install Exp globally on my windows 10.
Apparently adding C:\Users\~\AppData\Roaming\npm ~ being your username in the pc, to environment variables will solve the problem.
It seems exp doesn't installed correctly.
Please check by the following command:
1. npm list -g
2. npm view exp version
3. npm list -g --depth=0
3rd will give you list of packages something like this:
├── #angular/cli#1.7.4
├── #ngtools/json-schema#1.2.0
├── #ngtools/logger#1.1.2
├── #ngtools/webpack#1.10.2
├── async#2.6.1
├── asynch#0.5.2
├── hsbot#1.0.3
├── istanbul#0.4.5
├── n#2.1.12
├── node-gyp#3.6.2
├── npm#6.1.0
├── r-script#0.0.3
├── readline#1.3.0
├── typescript#2.8.1
If still, you found an error. Try to re-install it using root user.
You can follow this step:
npm uninstall -g exp (Remove corrupted package if so)
npm cache clean --force (This is not necessary. But, sometime npm cache gets confused)
npm i -g exp (And reinstall again exp package)
Maybe, you can install expo-cli.
Use this code:
npm install -g expo-cli

Issue with installation of PhantomJS

I get an issue when setting up PhantomJS on Ubuntu 14.04, I used NPM to install it but it doesn't work and the installation is stopped at "70%"...
Command : sudo npm install phantomjs --save
> phantomjs#1.9.17 install /var/www/gestiaweb/GestionDettes.3000/node_modules/phantomjs
> node install.js
Downloading https://bitbucket.org/ariya/phantomjs/downloads/phantomjs-1.9.8-linux-x86_64.tar.bz2
Saving to /var/www/gestiaweb/GestionDettes.3000/node_modules/phantomjs/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2
Receiving...
[============================------------] 70% 0.0s
Received 12854K total.
Extracting tar contents (via spawned process)
Removing /var/www/gestiaweb/GestionDettes.3000/node_modules/phantomjs/lib/phantom
Copying extracted folder /var/www/gestiaweb/GestionDettes.3000/node_modules/phantomjs/phantomjs/phantomjs-1.9.8-linux-x86_64.tar.bz2-extract-1435657830806/phantomjs-1.9.8-linux-x86_64 -> /var/www/gestiaweb/GestionDettes.3000/node_modules/phantomjs/lib/phantom
Writing location.js file
Done. Phantomjs binary available at /var/www/gestiaweb/GestionDettes.3000/node_modules/phantomjs/lib/phantom/bin/phantomjs
phantomjs#1.9.17 node_modules/phantomjs
├── which#1.0.9
├── progress#1.1.8
├── kew#0.4.0
├── request-progress#0.3.1 (throttleit#0.0.2)
├── adm-zip#0.4.4
├── npmconf#2.1.1 (ini#1.3.4, uid-number#0.0.5, inherits#2.0.1, once#1.3.2, osenv#0.1.3, config-chain#1.1.9, nopt#3.0.3, semver#4.3.6, mkdirp#0.5.1)
└── request#2.42.0 (caseless#0.6.0, forever-agent#0.5.2, aws-sign2#0.5.0, stringstream#0.0.4, oauth-sign#0.4.0, tunnel-agent#0.4.0, json-stringify-safe#5.0.1, qs#1.2.2, node-uuid#1.4.3, mime-types#1.0.2, form-data#0.1.4, bl#0.9.4, http-signature#0.10.1, tough-cookie#2.0.0, hawk#1.1.1)
icecom#web-test:/var/www/gestiaweb/GestionDettes.3000$
Put the executable into a directory that is in PATH (or put a symlink into PATH) or let NPM install it globally:
npm -g install phantomjs

Installing Yeoman on Yosemite

I'm on Yosemite, with Homebrew, Node and NPM installed.
Homebrew 0.9.5
Node v0.12.3
NPM 2.9.1
For whatever reason, I can't get Yeoman to properly install. The install seems to go fine, no errors, but when I check to confirm the install it wont give me the --version, nor can I execute the yo function...
Gregs-MacBook-Pro:~ G$ npm install -g yo
/Users/G/npm/bin/yo -> /Users/G/npm/lib/node_modules/yo/lib/cli.js
> yo#1.4.6 postinstall /Users/G/npm/lib/node_modules/yo
> yodoctor
Yeoman Doctor
Running sanity checks on your system
✔ Global configuration file is valid
✔ No .bowerrc file in home directory
✔ No .yo-rc.json file in home directory
✔ NODE_PATH matches the npm root
Everything looks all right!
yo#1.4.6 /Users/G/npm/lib/node_modules/yo
├── titleize#1.0.0
├── array-uniq#1.0.2
├── figures#1.3.5
├── user-home#1.1.1
├── opn#1.0.2
├── async#0.9.2
├── humanize-string#1.0.1 (decamelize#1.0.0)
├── sort-on#1.2.0 (dot-prop#2.0.0)
├── yeoman-character#1.0.1 (supports-color#1.3.1)
├── string-length#1.0.0 (strip-ansi#2.0.1)
├── cross-spawn#0.2.9 (lru-cache#2.6.4)
├── findup#0.1.5 (commander#2.1.0, colors#0.6.2)
├── chalk#1.0.0 (escape-string-regexp#1.0.3, ansi-styles#2.0.1, supports-color#1.3.1, strip-ansi#2.0.1, has-ansi#1.0.3)
├── yosay#1.0.4 (ansi-regex#1.1.1, ansi-styles#2.0.1, word-wrap#1.0.3, strip-ansi#2.0.1, pad-component#0.0.1, taketalk#1.0.0, minimist#1.1.1)
├── root-check#1.0.0 (sudo-block#1.2.0, downgrade-root#1.1.0)
├── update-notifier#0.3.2 (is-npm#1.0.0, latest-version#1.0.0, semver-diff#2.0.0)
├── package-json#1.1.0 (registry-url#3.0.3)
├── npm-keyword#1.1.1 (registry-url#3.0.3)
├── meow#3.1.0 (object-assign#2.0.0, minimist#1.1.1, camelcase-keys#1.0.0, indent-string#1.2.1)
├── got#2.9.2 (lowercase-keys#1.0.0, object-assign#2.0.0, timed-out#2.0.0, is-stream#1.0.1, prepend-http#1.0.1, nested-error-stacks#1.0.0, statuses#1.2.1, infinity-agent#2.0.3, read-all-stream#2.1.2, duplexify#3.4.0)
├── fullname#1.1.0 (npmconf#2.1.2)
├── yeoman-environment#1.2.5 (escape-string-regexp#1.0.3, log-symbols#1.0.2, untildify#2.0.0, diff#1.4.0, text-table#0.2.0, debug#2.2.0, mem-fs#1.1.0, grouped-queue#0.3.0, globby#1.2.0)
├── configstore#0.3.2 (object-assign#2.0.0, xdg-basedir#1.0.1, osenv#0.1.1, graceful-fs#3.0.7, uuid#2.0.1, mkdirp#0.5.1, js-yaml#3.3.1)
├── lodash#3.9.2
├── insight#0.5.3 (object-assign#2.0.0, lodash.debounce#3.1.0, os-name#1.0.3, tough-cookie#0.12.1, request#2.55.0)
├── yeoman-doctor#1.3.2 (object-values#1.0.0, log-symbols#1.0.2, each-async#1.1.1, twig#0.7.2)
└── inquirer#0.8.5 (ansi-regex#1.1.1, cli-width#1.0.1, through#2.3.7, readline2#0.1.1, rx#2.5.2)
Gregs-MacBook-Pro:~ G$ yo -v
-bash: yo: command not found
I've opened the .bashrc (have to use sudo to be able to open + save it). Without sudo I can't save the changes.
sudo nano /.bashrc
The bashrc file reads:
# NPM packages in homedir
NPM_PACKAGES="$HOME/.npm-packages"
# Tell our environment about user-installed node tools
PATH="$NPM_PACKAGES/bin:$PATH"
# Unset manpath so we can inherit from /etc/manpath via the `manpath` command
unset MANPATH # delete if you already modified MANPATH elsewhere in your configuration
MANPATH="$NPM_PACKAGES/share/man:$(manpath)"
# Tell Node about these packages
NODE_PATH="$NPM_PACKAGES/lib/node_modules:$NODE_PATH"
I've tried installing Node thru Homebrew first and found out about this issue which I couldnt resolve either. https://gist.github.com/DanHerbert/9520689
Since that didn't I blew everything away in terminal, including node, npm, and homebrew.
Now I'm stuck, npm lets me install packages grunt-cli, bower, and yeoman, but any time I try calling those packages I get:
-bash: yo: command not found
I'm assuming it has something to do with the /.bashrc contents, somebody help :(
I had the same problem under Yosemite.
My solution was:
sudo find /usr/local/ -name yo
/usr/local//Cellar/node/4.2.1/libexec/npm/bin/yo
open $HOME/.profile
export NODE_PATH="/usr/local/lib/node_modules"
export PATH="/usr/local/Cellar/node/4.2.1/libexec/npm/bin:$PATH"
export NODE_PATH=$NODE_PATH:/usr/local/Cellar/node/4.2.1/libexec/npm/lib/node_modules
open new terminal:
yo --version
1.4.8
perhaps your node version is a problem. At beginning after install 'brew install node' I had too
node --version
v0.12.7
After
brew update
and reinstall node
node --version
v4.2.1