Registry / devops / vue2-to-3

vue2-to-3

JSON →
library0.4.5jsnpmunverified

A CLI tool that automatically migrates Vue 2 Options API JavaScript files to Vue 3 Composition API style. Current stable version is 0.4.5 (beta). Release cadence is irregular; maintained by a single developer. Key differentiator: it splits Vue 2 component options (data, methods, computed) into separate Composition API files, factoring out logical concerns into individual composition functions. Currently supports only .js files, planned support for .ts and .vue SFC. Requires Vue 2.x as a peer dependency for initial project, but the output is Vue 3 compatible.

npm install vue2-to-3
INSTALL
IMPORT
SIG · VUE2-TO-3
V
vue2-to-3
devopsjavascriptv0.4.5
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

vue2-to-3
npx vue2-to-3 ./src/component.js
npm install vue2-to-3 --save-dev && require('vue2-to-3')
This is a CLI tool, not a library. Use via npx or global install with -g flag.
vue2-to-3 (migrate command)
migrate ./src/Component.js
migrate --input ./src/Component.js --output ./dist
The command is `migrate` and takes a single file path as argument. Options like --output are not supported yet.
ESM-only usage
import { reactive } from 'vue'
const Vue = require('vue'); Vue.reactive
The tool outputs ESM imports since it targets Vue 3 and Composition API.

Demonstrates global install of the CLI tool, creation of a Vue 2 Options API component, running the migration, and viewing the transformed Vue 3 Composition API output.

npm i -g vue2-to-3 # Create a sample Vue 2 component cat > HelloWorld.js << 'EOF' export default { name: 'HelloWorld', data: () => ({ some: 0, another: 0, foo: ['potato'], }), methods: { somePlus() { this.some++; }, anotherPlus() { this.another++; }, }, }; EOF migrate ./HelloWorld.js cat HelloWorld.js # Also creates CompositionSome.js and CompositionAnother.js
Debug
Known issues
breakingOnly .js files are supported. .ts and .vue files will be ignored or cause errors.
fix
Convert .ts to .js before migration, or wait for future updates.
affects: <1.0
breakingThe tool modifies the input file in-place. There is no backup or --dry-run option.
fix
Always version-control your files or create a backup before running the migration.
affects: <1.0
gotchaThe tool creates new files (Composition*.js) in the same directory. If a file with the same name exists, it may be overwritten without warning.
fix
Check the target directory for naming conflicts before running migration.
affects: <1.0
deprecatedThe tool is in beta; it may not migrate all Vue 2 patterns correctly, especially advanced features like mixins, filters, or custom directives.
fix
Review the migrated code manually and fix any issues.
affects: >=0.0.0
Errors
Common errors & fixes
migrate: command not found
The package was not installed globally or npx was not used.
fix
Run `npm i -g vue2-to-3` or use `npx vue2-to-3 migrate ./file.js`
Error: Cannot find module 'vue'
The tool requires vue to be installed in the project, even though it's a peer dependency.
fix
Run `npm install vue` in your project root.
TypeError: Cannot read property 'data' of undefined
The input file does not have a default export with the expected Vue 2 Options API structure.
fix
Ensure the file exports an object with `data`, `methods`, `computed`, etc.
Upgrade
Version history
0.4.5latest on npm
Audit
Dependencies
vueoptionalpeer dependency: required for Vue 2 projects being migrated; not needed at runtime for the tool itself
Agent activity
4 hits · last 30 days
node
4
Resources
vue2-to-3 — npm install vue2-to-3 · libregistry