React-native init error - node.js

I'm trying to install React-native to my ubuntu 14.04. I have sucessfully installed react-native-cli, but when I'm trying to run react-native init reactApp trene is an error:
pavlov#pavlov-System-Product-Name:~$ node -v
v0.12.7
pavlov#pavlov-System-Product-Name:~$ react-native init reactApp
prompt: Directory reactApp already exist. Continue?: (no) y
This will walk you through creating a new React Native project in /home/pavlov/reactApp
Installing react-native package from npm...
You are currently running Node v0.12.7 but React Native requires >=4. Please use a supported version of Node.
See https://facebook.github.io/react-native/docs/getting-started.html
/home/pavlov/reactApp/node_modules/react-native/local-cli/cli.js:56
const setupEnvScript = /^win/.test(process.platform)
^^^^^
SyntaxError: Use of const in strict mode.
at exports.runInThisContext (vm.js:73:16)
at Module._compile (module.js:443:25)
at Module._extensions..js (module.js:478:10)
at Object.require.extensions.(anonymous function) [as .js] (/home/pavlov/reactApp/node_modules/babel-core/lib/api/register/node.js:214:7)
at Module.load (module.js:355:32)
at Function.Module._load (module.js:310:12)
at Module.require (module.js:365:17)
at require (module.js:384:17)
at Object.<anonymous> (/home/pavlov/reactApp/node_modules/react-native/cli.js:15:18)
at Module._compile (module.js:460:26)
How can i fix it?

You definitely need to install Node 4.0 or higher. Actually it even says it in your console output.
Here is how i installed Node on my Ubuntu:
sudo apt-get install curl
curl --silent --location https://deb.nodesource.com/setup_4.x | sudo bash -
sudo apt-get install nodejs
Good luck!

Go to https://nodejs.org/en/ and download the latest version, in this case v4.4.3.

Related

Which one is right on ubuntu node or nodejs ? How do get the current working version?

I am try to install webpack-dev-server but it need latest version of nodejs as i am on ubuntu 20.04 and when i try to update with nvm and it didn't update nodejs and it try to remove it with this Q&A answer https://askubuntu.com/a/786019 and after that i try to install nodejs sudo apt-get install nodejs , npm sudo apt-get install npm and even try to get latest nodejs with n offical package after all of this when i type node -v it says v16.13.1 which is the latest stable version and when i type nodejs -v it says v10.19.0 which is the version which i get form ubuntu package manager but when i type npm -v it throw this gibberish
throw err;
^
Error: Cannot find module 'semver'
Require stack:
- /usr/share/npm/lib/utils/unsupported.js
- /usr/share/npm/bin/npm-cli.js
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/usr/share/npm/lib/utils/unsupported.js:2:14)
at Module._compile (node:internal/modules/cjs/loader:1101:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1153:10)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19) {
code: 'MODULE_NOT_FOUND',
requireStack: [
'/usr/share/npm/lib/utils/unsupported.js',
'/usr/share/npm/bin/npm-cli.js'
]
}```
after all How do i get the latest working version of nodejs which is i can run npm,and how do i remove this confusion what to use and what to install next time when i try to update
I try to solve it by my own so i google a lot but the problem was with the PPAs and after make so many mistakes it install with the official nodejs github documentation. so the problem is solved : )

How to solve unexpected token issue in yarn installation

I install yarn on my server without any error, when I run yarn -v I get this error
I think the yarn did not install properly, what is wrong?
/usr/share/yarn/lib/cli.js:46100
let {
^
SyntaxError: Unexpected token {
at exports.runInThisContext (vm.js:53:16)
at Module._compile (module.js:374:25)
at Object.Module._extensions..js (module.js:417:10)
at Module.load (module.js:344:32)
at Function.Module._load (module.js:301:12)
at Module.require (module.js:354:17)
at require (internal/module.js:12:17)
at Object.<anonymous> (/usr/share/yarn/bin/yarn.js:24:13)
at Module._compile (module.js:410:26)
at Object.Module._extensions..js (module.js:417:10)
The error is caused by the old version of nodejs (usually lower than v6).
First install the latest stable version of nodejs or more recent version than you are using now.
# Using Ubuntu
curl -sL https://deb.nodesource.com/setup_lts.x | sudo -E bash -
sudo apt-get install -y nodejs
# Using Debian, as root
curl -sL https://deb.nodesource.com/setup_lts.x | bash -
apt-get install -y nodejs
https://github.com/nodesource/distributions/blob/master/README.md
Then install yarn:
https://yarnpkg.com/en/docs/install#debian-stable
Got same issue. The problem was that my PC has crashed while yarn install. Resolved with:
yarn cache clean

Express not working with node 9.x

I have an Ubuntu box with node - v 9.5.0 and npm - 5.6.0 versions. I am trying to use expressjs (http://expressjs.com), but unable to run it. It works fine for node v 4.x.x.
$ express -h
module.js:557
throw err;
^
Error: Cannot find module 'commander'
at Function.Module._resolveFilename (module.js:555:15)
at Function.Module._load (module.js:482:25)
at Module.require (module.js:604:17)
at require (internal/module.js:11:18)
at Object.<anonymous> (/usr/lib/nodejs/express-generator/bin/express:3:15)
at Module._compile (module.js:660:30)
at Object.Module._extensions..js (module.js:671:10)
at Module.load (module.js:573:32)
at tryModuleLoad (module.js:513:12)
at Function.Module._load (module.js:505:3)
What is it that I am missing here?
Ubuntu's packages seem to be outdated.
Installing using apt-get node-express-generator gives this error.
Installing using npm i -g express-generator works fine.
Please try to follow the preceding steps.
Install the current version of NodeJS
Uninstall all modules with npm uninstall and rm -fr ~/.npm
Reinstall express-generator
Hope it helps.

Unable to change node version using nvm

I am unable to resolve this error. I don't even know what's causing it. I have the latest version of npm and the most stable version of node.
$ nvm use 0.10.40
/Users/Test/.nvm/v0.10.40/lib/node_modules/npm/lib/utils/unsupported.js:27
console.error(`a bug known to break npm. Please update to at least ${r
^
SyntaxError: Unexpected token ILLEGAL
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at /Users/Test/.nvm/v0.10.40/lib/node_modules/npm/bin/npm-cli.js:19:21
at Object.<anonymous> (/Users/Test/.nvm/v0.10.40/lib/node_modules/npm/bin/npm-cli.js:92:3)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
nvm is not compatible with the npm config "prefix" option: currently set to ""
Run npm config delete prefix or nvm use --delete-prefix v0.10.40 to unset it.
I tried to run nvm use --delete-prefix v0.10.40 but that gives me the same error as well.
You probably need up update Node.js which you can do by visiting
https://nodejs.org/en/
See:
https://github.com/npm/npm/issues/18963
Update your nodejs version, install the nvm https://github.com/creationix/nvm.
Later install the version choice of nodejs
# e.g, replace for a current version
nvm install 9.3.0

gitbook-cli install error, gitbook-cli -v cannot be use

after i install the nodejs and npm , gitbook-cli ,there is an error.like this:
[root#vagrant-centos65 vagrant]# gitbook -v
/usr/lib/node_modules/gitbook-cli/node_modules/fs-extra/lib/index.js:3
const assign = require('./util/assign')
^^^^^
SyntaxError: Use of const in strict mode.
at Module._compile (module.js:439:25)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
at Function.Module._load (module.js:312:12)
at Module.require (module.js:364:17)
at require (module.js:380:17)
at Object.<anonymous> (/usr/lib/node_modules/gitbook-cli/lib/config.js:2:10)
at Module._compile (module.js:456:26)
at Object.Module._extensions..js (module.js:474:10)
at Module.load (module.js:356:32)
[root#vagrant-centos65 vagrant]# npm -v
1.3.6
[root#vagrant-centos65 vagrant]# node -v
v0.10.48
my nodejs version and npm are v0.10.48 ,1.3.6 ,what should i do ,please help me .
As this answer explain, const support is not enabled by default in node.js version 0.10 and require --harmony flag if you want to use it.
As this version of fs-extra package use const keyword in his index.js file, you got this error.
You can have a look at this compatibility table for a summary for const and let support by version.
Just upgrade your node.js version to solve this issue.
Also, I don't think it is a good idea to launch gitbook as root user.
thanks # TGrif , i upgrade my nodejs ,and its worked.
npm cache clean -f
npm install -g n
n stable
ln -sf /usr/local/n/versions/node/8.0.0/bin/node /usr/bin/node
How do I update Node.js?

Resources