How do I check which babel version is on my windows 10 OS? - babeljs

I need help to find which version of Babel is on my Windows Machine. I have installed it using
npm install --save-dev babel-cli babel-preset-env.
How do I check which version is on my Windows OS?

After you finish installing Babel, your package.json file should look like this:
{
"name": "my-project",
"version": "1.0.0",
"devDependencies": {
"babel-cli": "^6.0.0"
}
}
So you can find your Babel version in this configuration file.

Try this at the command line:
npm list babel-cli

You can also check the version of babel-cli by finding the babel-cli folder in node_modules and looking at the version property of the package.json that is at the base of that folder.
If babel-cli was installed globally via -g flag of npm install, you could check the version by executing command babel --version.
Hopefully the helps!

As the babel is updated to babel 7,
check using
npm list #babel/cli
or
npm list #babel/core

possibly your local ./node_modules/.bin is not in $PATH check out
this previous question for further info.

babel --version
You can figure this out by typing in the command line:
babel --help, look over the output and you can see other options that you might need.
Good luck

Related

Trying to run babel : "cannot find module #babel/core"

I'm trying to set up a build environment to explore react.
My build process uses gulp.
I installed packages like this:
npm install --save-dev gulp-babel#7 babel-core babel-preset-env
After discovering that I needed to install something related to babel and react I also ran:
npm install --save-dev #babel/preset-react
My .babelrc has this:
{ "presets": ["#babel/preset-react"] }
My gulpfile has this:
gulp.task('scripts', function() {
return gulp.src(['./src/js/main.js' ])
.pipe(babel({
presets : ['#babel/preset/react']
}))
.pipe(concat('test.js'))
.pipe(gulp.dest('./js'))
.pipe(uglify())
.pipe(rename('test.min.js'))
.pipe(gulp.dest('./js')) ;
});
When I run 'gulp scripts' I get this:
[22:51:14] Using gulpfile ~/play/learning-react-2/gulpfile.js
[22:51:14] Starting 'scripts'...
[22:51:14] 'scripts' errored after 59 ms
[22:51:14] Error in plugin "gulp-babel"
Message:
Cannot find module '#babel/core' (While processing preset: "/home/bob/play/learning-react-2/node_modules/#babel/preset-react/lib/index.js")
I deleted babel-core from node_modules, and reinstalled it using the command:
npm install --save-dev #babel/core
If I look at the contents of node_modules, I see these packages related to babel:
babel-code-frame/
babel-helper-builder-binary-assignment-operator-visitor/
babel-helper-call-delegate/
babel-helper-define-map/
babel-helper-explode-assignable-expression/
babel-helper-function-name/
babel-helper-get-function-arity/
babel-helper-hoist-variables/
babel-helper-optimise-call-expression/
babel-helper-regex/
babel-helper-remap-async-to-generator/
babel-helper-replace-supers/
babel-messages/
babel-plugin-check-es2015-constants/
babel-plugin-syntax-async-functions/
babel-plugin-syntax-exponentiation-operator/
babel-plugin-syntax-trailing-function-commas/
babel-plugin-transform-async-to-generator/
babel-plugin-transform-es2015-arrow-functions/
babel-plugin-transform-es2015-block-scoped-functions/
babel-plugin-transform-es2015-block-scoping/
babel-plugin-transform-es2015-classes/
babel-plugin-transform-es2015-computed-properties/
babel-plugin-transform-es2015-destructuring/
babel-plugin-transform-es2015-duplicate-keys/
babel-plugin-transform-es2015-for-of/
babel-plugin-transform-es2015-function-name/
babel-plugin-transform-es2015-literals/
babel-plugin-transform-es2015-modules-amd/
babel-plugin-transform-es2015-modules-commonjs/
babel-plugin-transform-es2015-modules-systemjs/
babel-plugin-transform-es2015-modules-umd/
babel-plugin-transform-es2015-object-super/
babel-plugin-transform-es2015-parameters/
babel-plugin-transform-es2015-shorthand-properties/
babel-plugin-transform-es2015-spread/
babel-plugin-transform-es2015-sticky-regex/
babel-plugin-transform-es2015-template-literals/
babel-plugin-transform-es2015-typeof-symbol/
babel-plugin-transform-es2015-unicode-regex/
babel-plugin-transform-exponentiation-operator/
babel-plugin-transform-regenerator/
babel-plugin-transform-strict-mode/
babel-preset-env/
babel-runtime/
babel-template/
babel-traverse/
babel-types/
I'm guessing that at least one of them is "babel core"
So... how do I actually run babel from gulp? How do I run it at all?
I had the same issue. I resolved it by removing node_modules and I reinstalled packages (with yarn OR npm install). The problem was fixed.
In case Victor's answer doesn't help, it may be worth a try to clean your machine's package cache by running npm cache clean/yarn cache clean or removing the cache folder manually.

Symlink to file within same NPM module

In a GitHub module, it is possible to symlink to another file within the same module. But is it possible to have this symlink survive / work in the NPM package of same module?
I'm using a Mac and so far I've done
ln -s [filename-1.0.4.js] [filename.js]
This works great for github.io-pages, but the file disappears when published to NPM.
After some rounds with NPM support it seems that only folders can be linked with npm link
So the answer to my question is no. Here's the documentation for npm link
And here is the answer from support:
[...]
To create a symlink in a package.json, we recommend using the scripts field.
For example:
"scripts": {
"postinstall": "npm link ../somelocallib",
"postupdate": "npm link ../somelocallib"
}
[...]

Install specific branch from github using Npm

I would like to install bootstrap-loader from github in my project using npm
Currently they are maintaining two version of this project which are comaptible with webpack version 1 and 2.
I would like to install version 1. What npm command I should use to install this?
I tried using below one but it is not working.
npm install git://github.com/shakacode/bootstrap-loader.git[#v1] --Save
There are extra square brackets in the command you tried.
To install the latest version from the brach-name branch, you can use:
npm install "https://github.com/shakacode/bootstrap-loader.git#branch-name" --save
npm: npm install username/repo#branchName --save
yarn: yarn add username/repo#branchName
e.g. npm i betimer/rtc-attach#master --save (my username is betimer)
// this will appear in your package.json:
"rtc-attach": "github:betimer/rtc-attach#master"
One thing I also want to mention: it's not a good idea to check in the package.json for the build server auto pull the change. Instead, put the npm i (first command) into the build command, and let server just install and replace the package.
One more note, if the package.json private is set to true, may impact sometimes.
you can give git pattern as version, yarn and npm are clever enough to resolve from a git repo.
yarn add any-package#user-name/repo-name#branch-name
or for npm
npm install --save any-package#user-name/repo-name#branch-name
Another approach would be to add the following line to package.json dependencies:
"package-name": "user/repo#branch"
For example:
"dependencies": {
... other dependencies ...
"react-native": "facebook/react-native#master"
}
And then do npm install or yarn install
I'm using SSH to authenticate my GitHub account and have a couple dependencies in my project installed as follows:
"dependencies": {
"<dependency name>": "git+ssh://git#github.com/<github username>/<repository name>.git#<release version | branch>"
}
Had to put the url in quotes for it work
npm install "https://github.com/shakacode/bootstrap-loader.git#v1" --save
Tried suggested answers, but got it working only with this prefix approach:
npm i github:user/repo.git#version --save -D
Only solution working for me:
$ npm i https://github.com/{USER}/{REPO}/tarball/{BRANCH} --save
as explained here.
Both below versions work for me as of beginning of 2023:
npm i "github:shakacode#bootstrap-loader"
npm i "https://github.com/shakacode/tree/bootstrap-loader/"
The Doc of the npm defines that only tag/version can be specified after repo_url.
Here is the Doc: https://docs.npmjs.com/cli/install

How to compile and run an ES6 file with node when using babel6?

I installed the latest version 6 of babel, babel-core and babel-loader.
How can I run an ES6 file in Node with Babel6?
Previously I would run the command
babel-node server.js
but now I get this message:
The CLI has been moved into the package `babel-cli`. See http://babeljs.io/docs/usage/cli/.
None of the instructions on that page say how to do this.
The message could be clearer. You've installed the babel package and you should have installed the babel-cli package.
npm uninstall babel
npm install babel-cli
Upon installing babel-cli I also had to specify the es2015 loader and to specifically use my local babel-node package since I don't have it installed globally.
./node_modules/.bin/babel-node --presets es2015 server.js

Ionic framework - 'ionic' is not recognized as an internal or external command

I was trying to install ionic and create a sample project on it since morning. But, was facing a series of issues since then. Tried solving them one by one. Atlast restarted my machine and opened command prompt to build the sample project and tried
path of the sample project> ionic build android
But, i kept on facing the error that states 'ionic' is not recognized as an internal or external command.
I tried clearing the cache and reinstalling ionic in my machine. Still, I face the same issue of ionic is not recognized as an internal or external command.
Can somebody help me out on this issue?
Thanks
Manikandan J
Somehow , my npm path was not there in PATH environmental Variable
So after adding C:\Users\XXXXX\AppData\Roaming\npm to my PATH variable my problem solved :-)
Try to install the ionic framework with the -g parameter, so the installation will be globall, like this:
npm install -g ionic
-g parameter mean "its binaries end up in your PATH environment variable."
If you're on Windows 10 (and possibly Vista/8/8.1) you need to run cmd.exe as an administrator. Now when you run the commands below, your environment settings will be made.
npm install -g cordova ionic
Check if the configuration is broken or not. the update might have installed it in the wrong place.
First check: npm config get prefix
In my case It wasn't set to /usr/local but in /usr/Roaming.
So to fix it, use: npm config set prefix
Problem solved! :)
After several hours of struggle I fixed it by the below steps:
uninstall node js restart the system .
install the node js (current version).
check your node js path in System variable in an
environmental variable.
Right click the command prompt and select run as administrator. Type cd\ now get into the npm path folder by cd <YourNpmPath>\npm install -g ionic#4
That's it . Now it is globally available throughout the system.
I ran this command to uninstall:
npm uninstall -g ionic cordova
and then ran the install:
npm install -g ionic cordova
and then everything started working again.
Insert this into your system path. This happens because node modules are not seen but when you do this you make the path to the module. They are found in this location
C:\Users\[username]\AppData\Roaming\npm
Below simple steps to follow to get it working:
install Node.js
Install Ionic and cordova : npm install -g cordova ionic
create a simple project: ionic start mySimpleApp tabs
cd mySimpleApp
ionic cordova platform add android
Build the project: ionic build android
For the benefit of searchers, the other answers didn't work for me.
I deleted the 'Ionic' folder from:
C:\Users\..{me}..\AppData\Roaming\npm\node_modules
Then installed again with:
npm install -g ionic cordova
That fixed it.
I solve the problem on windows 10.The problem was that the environment variables don't contain a path to the ionic folder.
Just do:
npm config set prefix
And then
npm install -g ionic cordova
setting the path variable to C:\Users\«user name folder»\appdata\Roaming\npm helped me to resolve the issue. Please try
uninstall the old version
npm uninstall -g ionic
and try to install it again with the new version
npm install -g #ionic/cli
In my situation, I thought Ionic did not install,
but after I had changed my Windows User-Name, npm did for some reason still install on the last %AppData% folder path.
for example correct-path for new user-name is:
C:\Users\Admin\AppData\Roaming\npm
but npm did use:
C:\Users\Abc\AppData\Roaming\npm
have moved that folder contents to the right place and all just works!
But to finally fix the issue from its root cause I updated NPM settings like:
npm config -g set prefix "%AppData%\npm"
npm config -g set cache "%AppData%\npm-cache"
npm config -g get prefix
And ensured my PATH environment-variable includes the correct NPM directory.
This issue occurs when we change the path variables manually.Because of this change system doesn't find libraries for the command which needed to be executed.
While installing ionic cordova, ionic cli takes cares by adding path variable in your environment.Hope this content helps
path -
C:\user\system_name\AppData\Roaming\npm
I had the same problem on Windows, and I find solution by navigating the command prompt to
C:\Users\[username]\AppData\Roaming\npm>
Cordova, Ionic, etc. are found here.
The following steps worked for me in 2022:
Run the command prompt as Admin. This is mandatory to ensure that ionic is installed globally, otherwise you would continue to see the same error message despite installing ionic.
Type this command and hit enter: npm i -g #ionic/cli
That's it!
'ionic/java/cordova etc..' is not recognized as an internal or external command
for ionic or cordova install it from node using npm install -g ionic/cordova command.
This kind of messages comes whenever its PATH not set properly for other programs like java. System has to recognize your command available on your system or not. This can be identified only when you set your environment variable.
use this for setting your path
SET PATH = %PATH%; your app path to bin
Just follow this video, you have to set your path correctly.
http://learn.ionicframework.com/videos/windows-android/
1: Download and Install Java then open your system environment variables, and add to or create a new user variable called PATH with the full path to the bin folder of the new Java SDK installation.
2: Download Apache Ant then add the full path to the bin/ folder to the end of your PATH environment variable.
3: Add Android to PATH :Open up your environment variables setting and add the full path to both the adt-bundle/sdk/platform-tools/ folder and the adt-bundle/sdk/tools/ folder to the end of your PATH variable:
4.Install nodeJs and now you can do
npm install -g cordova ionic
I started getting this same error in the Console2 command prompt. I checked the environment variables and reinstalled ionic and cordova but this did not fixed it.
I then tried ionic in Node.js command prompt and it worked perfectly. So if you follow the other advice and it still doesn't work, try a different command prompt.
I think you should copy the bin file to the system variables and it should be fine, at least I try it on Win7 and it worked. I also got the same prob like this before.
Right click Computer, choose Properties, Advanced system settings and edit environment variables.
Try reinstalling the ionic
npm install ionic -g
uninstall ionic npm package and then clear all npm cache in appdata and then install ionic
npm install -g ionic
ionic info
you must install ionic package has global so use -g.
ionic info command is used to check the ionic information
Well, after trying several answers from many posts like this one and realizing that my environment variables were there too, I ran the
npm install -g cordova ionic
from the inside of nodejs folder in Program Files with windows prompt as administrator.
Initially I was installing it in my dev folder in D:\ partition. Hope it helps someone.
Probably you doesn't have ionic installed in your device.
First check in terminal/cmd, have you installed ionic or not?
you can check it with following command:
ionic -v
C:\Program Files\nodejs\bin
try adding this to your user and environment variables, under environment variables, and then close the command prompt window and open.
I got my problem resolved :)
npm install -g cordova ionic
and then
ionic start myApp tabs
and then
cd myApp
ionic serve
Firstly uninstall the ionic module from the project by using the following command.
npm uninstall -g ionic cordova
Then install ionic and cordova dependencies seperately as follows.
npm install -g ionic
npm install -g cordova
Please check whether ionic cli is installed or not globally and locally both
Node versions
Check if you are using the nvm,
you would have installed the ionc cli with node version 14.X, and now you might be using node 16.X or latest, this is why the ionic cli is not working in latest node version.
check list of node versions if by using nvm:
nvm list
try changing the node version to previous,
NVM user older node
change to older nvm:
nvm use 14.x.x
or your version in list