Hello I am getting an issue when trying to run react-native init.
SyntaxError: Unexpected token ...
/Users/jordan/Projects/React/LiveInstagram/node_modules/metro-bundler/build/lib/TerminalClass.js:141
this._nextStatusStr = util.format(format, ...args);
Does anyone know how I can remedy this issue? Thanks!
There are compatibility issues in the updated react-native cli. Using the downgraded version solves this problem.
$ react-native init [project name] --version 0.38.0
https://github.com/facebook/react-native/issues/11384
Currently it works for me with node v8. My solution:
sudo npm install -g npm
sudo npm cache clean -f
sudo npm install -g n
sudo n stable
So I completely uninstalled Node then reinstalled it and react-native-cli and it worked correctly.
I had the same problem with nodejs v4, solve this by updating nodejs and npm.
sudo purge nodejs npm
curl -sL https://deb.nodesource.com/setup_8.x | sudo -E bash -
sudo apt-get install -y nodejs
Related
Image of my terminal in VSCode
I've tried uninstalling/reinstalling node and clearing the cache but I can't seem to figure it out. Any ideas?
I'm on Windows 10 if that helps
Try these:
Delete node_modules folder if you have one.
Delete package.lock.json.
Then...
sudo apt update
sudo apt upgrade
sudo apt install nodejs
npm install
It seems that it's conflicting with chokidar.
First of all you need to delete node_modules and package-lock.json not package.json
and then add cmd
npm install --force
if you are using Ubuntu OS use
sudo npm install
I had a similar issue before and I believe it has to do with your nodejs. I suggest you reinstall your node cause it might solve the issue.
Try purging it
sudo apt-get purge nodejs
Then remove dependencies
sudo apt-get autoremove
Then reinstall
sudo apt install nodejs
Also try updating your chokidar and axios to a newer version, yours is already depreciated.
I am getting a TypeError when running npm install -g react-native project on mac.
full error
TypeError: Cannot destructure property stat of 'undefined' or 'null'.
at Object. (/usr/local/lib/node_modules/npm/node_modules/#npmcli/node-gyp/lib/index.js:2:29)
Might be you are using npm#latest. Looks to me some issue with lates NPM, I have changed my version with RUN npm install npm#6.14.11 -g in my docker file working for me.
When I upgraded to Big Sur, I had the same issue. It's something to do with npm, not react-native.
Here's what I did to solve the problem:
Delete everything related to nodejs:
sudo rm -rf ~/.npm ~/.nvm ~/node_modules ~/.node-gyp ~/.npmrc ~/.node_repl_history
sudo rm -rf /usr/local/bin/npm /usr/local/bin/node-debug /usr/local/bin/node /usr/local/bin/node-gyp
sudo rm -rf /usr/local/share/man/man1/node* /usr/local/share/man/man1/npm*
sudo rm -rf /usr/local/include/node /usr/local/include/node_modules
sudo rm -rf /usr/local/lib/node /usr/local/lib/node_modules /usr/local/lib/dtrace/node.d
sudo rm -rf /opt/local/include/node /opt/local/bin/node /opt/local/lib/node
sudo rm -rf /usr/local/share/doc/node
sudo rm -rf /usr/local/share/systemtap/tapset/node.stp
brew uninstall node
brew doctor
brew cleanup --prune-prefix
And then install nvm again via:
curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.37.2/install.sh | bash
Now, I was able to install all of my dependencies since now I've got a fresh copy of npm(for me it was 6.4.1).
As usual, Mac OS updates tend to break stuff.
In case you're using NVM too (like me).
I faced this issue too and found that NVM is using a node version called 'system'. I never seen it before and NVM should be using the version I set it to use.
So I decided to update NVM. (See: https://github.com/nvm-sh/nvm/blob/master/README.md#installing-and-updating)
Seems to work after that.
You shouldn't be using npm install -g react-native.
Please read through the React Native docs on how to do your environment setup: https://reactnative.dev/docs/environment-setup
In case that you have the same error when running any command that has npm, you might have wrong npm version with node 8.
Running this will reverse your npm to node 6.
curl -qs https://www.npmjs.com/install.sh|npm_install=6.14.11 sh
Reference:
https://github.com/npm/cli/issues/2599
So I recently started using the zsh to code in python, i had to configure the environment variables for it and now im trying to start a small project in javascript and it won't let me use npm.
Trying to initialize the repo will throw this error at me:
npm init -y
zsh: /mnt/c/program files/nodejs//npm: bad interpreter: /bin/sh^M: no such file or directory
And of course it won't let me install packages.
Any suggestions? as I didn't find anything that could help me solve the problem.
Ok looks like what i had to do is install nodejs back again as this is a new shell, zsh didn't have it installed: If anyone has a similar issue you might wanna try the following :
curl -sL https://deb.nodesource.com/setup_15.x | sudo -E bash -
sudo apt-get install -y nodejs
and then
sudo apt-get install -y nodejs
Even though everything used to work couple of weeks ago, now I can not successfully create new react app with its templates.
When I try to run npx create-react-app my-app command, it only creates the folder with package.json, pckage-lock.json and node_modules. The public folder is missing and also, when I try to run npm start, it gives me an error saying:
npm ERR! missing script: start
npm ERR! A complete log of this run can be found in:
before it used to say happy hacking and the template page with react logo was displayed.
I tried to uninstall and install node again, clear cache but nothing helped. Any advice? Thank you so much!
My npm -v is 6.13.4 and node -v is v12.14.0
If you have installed create-react-app globally. remove that globally from you system
Try these steps
npm uninstall -g create-react-app
npx create-react-app app_name
cd app_name
npm start
Note- npx comes with npm 5.2+ and higher, see instructions for older
npm versions
Check this reactjs documentation.
Faced the same issue and fixed it by following the below steps:
Try to uninstall all existing global installation of create-react-app and check that they are removed properly by using the two commands below:
command for uninstalling: npm uninstall -g create-react-app
command for checking: which create-react-app
command for manual delete: rm -rf <path where create react app is located>
Once all the versions are removed, use: npx create-react-app <name_of_the_app>
For more details refer here
First, update the npm and node using following commands:
npm install -g npm
npm cache clean -f
npm install -g n
n stable
Remove globally installed create-react-app using:
npm uninstall -g create-react-app
Use npx for using create-react-app directly:
npx create-react-app <project-name>
I was having the same issue, and saw a lot of the same answers saying to uninstall create-react-app globally and reinstall using npx create-react-app my-app.
Downgrading my version of Node to 8.11.1 is what fixed it.
sudo npm install -g n
sudo n 8.11.1
node -v
> v8.11.1
After that I ran npx create-react-app my-app and it worked as expected.
I followed the documentation to create my first NestJS project.
Installing the Nest CLI with the command npm i -g #nestjs/cli was successful.
The output was:
+ #nestjs/cli#6.3.0
updated 1 package in 11.326s
However, when I try to scaffold a project with the Nest CLI:
nest new project-name
I get the following error:
zsh: command not found: nest
Some details about my environment:
OSX
iTerm
npm version 6.5.0
Use npx #nestjs/cli instead of nest
e.g. npx #nestjs/cli g controller pages
I was also getting the same console error when npm installing!
Erro was
#nestjs/cli
npm WARN deprecated resolve-url#0.2.1: https://github.com/lydell/resolve-url#deprecated
npm WARN deprecated urix#0.1.0: Please see https://github.com/lydell/urix#deprecated
npm WARN deprecated chokidar#2.1.8: Chokidar 2 will break on node v14+. Upgrade to chokidar 3 with 15x less dependencies.
npm WARN deprecated fsevents#1.2.13: fsevents 1 will break on node v14+ and could be using insecure binaries. Upgrade to fsevents 2.
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#nestjs/cli
npm WARN checkPermissions Missing write access to /usr/local/lib/node_modules/#nestjs
npm WARN notsup Unsupported engine for watchpack-chokidar2#2.0.0: wanted: {"node":"<8.10.0"} (current: {"node":"12.14.1","npm":"6.13.4"})
npm WARN notsup Not compatible with your version of node/npm: watchpack-chokidar2#2.0.0
How I wasn able to install =>
Solution
sudo npm install -g #nestjs/cli
Following command works in my windows 10
node -v
v14.16.0
npm -v
6.14.11
npx #nestjs/cli new project-name
I was having the same issue, what I did was:
Installed the latest node with npm install npm#latest -g
and then added the following to my .bash_profile
alias nest="/usr/local/Cellar/node/11.9.0/bin/nest"
Tested with nest --version and it worked.
For some reason the path is not being called correctly, hope it helps.
Working through a NestJS/Mongo DB tutorial i stumbled into this very same problem. After trying all of the solutions that were listed above, even turning my default profile back to bash instead of using zsh, i found that simply adding the /usr/local/bin and ~/.npm-global/bin to my path variable resolved the issue. Hopefully this helps someone else who may stumble on this in the future as well.
export $PATH="/usr/local/bin"
export $PATH="~/.npm-global/bin"
Were the two commands i ran from iTerm2 in order to add them to my PATH environment variable. Once this was done a simple
env
showed the entries in my $PATH environment variable and the nest -v command worked without any issues.
I had same error when I use GitBash.
I resoved it:
If you use windows:
Your use CMD: npm i -g #nestjs/cli
Then you can use gitbash:
Check version nestjs: nest --version
Create app nestjs: nest new name_project
I have faced same problem and solved ,following this
write the command NPM root -g
check where NPM is installed
add it to your path environment variable
You have to add the following line to your ~/.zshrc file:
source $HOME/.bashrc
This is needed so that the npm binaries are available on startup.
After all the answers that I tried, I used my method
After installing npm i -g #nestjs/cli in my mac terminal.
open bash file in macos by typing open ~/.bash_profile in mac terminal. Like you can type it anywhere.
Your bash will look like this and use this line
alias nest="~/.npm-global/lib/node_modules/#nestjs/cli/bin/nest.js"
Restart your mac for changes to be reflected in your terminal.
There you go nestjs cli is now working globally 2nd screenshot.
I have just succeeded with
npx #nets/cli new project
when asked what manager to choose from npm / yarn / pnpm
made choice for pnpm
cd project
npm run start
Take care!
Must use sudo in comandline for linux, otherwise the command nest cannot be add to /usr/local/bin folder:
sudo npm install -g #nestjs/cli
You can try to use sudo
sudo yarn global add #nestjs/cli
I got the same issue.
I just uninstalled and reinstalled nextjs.
Finally, I can use next -v