getyourguide / vue-class-migrator

Vue 3 Migration helper for applications using Vue 2.7
Apache License 2.0
57 stars 19 forks source link

How to run? #113

Open phoenix-oes opened 10 months ago

phoenix-oes commented 10 months ago
npm run migrate -- -d <my path>

This only results in

npm ERR! Missing script: "migrate"
npm ERR! 
npm ERR! To see a list of scripts, run:
npm ERR!   npm run

Moving to its globally installed location and trying to run from there results in:

> vue-class-migrator@0.0.3 migrate
> ts-node src/index.ts -d <the path I specified>

sh: 1: ts-node: not found

Installing ts-node and trying again...

> vue-class-migrator@0.0.3 migrate
> ts-node src/index.ts -d <my path again>

node:internal/modules/cjs/loader:1078
  throw err;
  ^

Error: Cannot find module './index.ts'
Require stack:
- /home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/src/imaginaryUncacheableRequireResolveScript
    at Module._resolveFilename (node:internal/modules/cjs/loader:1075:15)
    at Function.resolve (node:internal/modules/cjs/helpers:116:19)
    at requireResolveNonCached (/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/node_modules/ts-node/dist/bin.js:549:16)
    at getProjectSearchDir (/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/node_modules/ts-node/dist/bin.js:519:40)
    at phase3 (/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/node_modules/ts-node/dist/bin.js:267:27)
    at bootstrap (/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/node_modules/ts-node/dist/bin.js:47:30)
    at main (/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/node_modules/ts-node/dist/bin.js:33:12)
    at Object.<anonymous> (/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/node_modules/ts-node/dist/bin.js:579:5)
    at Module._compile (node:internal/modules/cjs/loader:1254:14)
    at Module._extensions..js (node:internal/modules/cjs/loader:1308:10) {
  code: 'MODULE_NOT_FOUND',
  requireStack: [
    '/home/<me>/.nvm/versions/node/v18.14.2/lib/node_modules/vue-class-migrator/src/imaginaryUncacheableRequireResolveScript'
  ]
}

Node.js v18.14.2

I'm pointing it to the folder where the .vue files that need to be updated are located.

Asuza commented 9 months ago

This is what worked for me, using Yarn.

yarn dlx vue-class-migrator -- -d .\src\
suits-at commented 8 months ago

I had the same problem, what worked for me was:

  1. installing it into the project where I wanted to make the migration (instead of globally)
  2. creating a migrate script inside my package.json (looks like this: "migrate": "vue-class-migrator -d ./src/pages/")
  3. calling this script via npm run migrate
s4v4g3 commented 8 months ago

after installing it globally you can run npx vue-class-migrator ...

dcecile commented 7 months ago

after installing it globally you can run npx vue-class-migrator ...

Specifically, the -- is invalid, so this needs to be npx vue-class-migrator -d <my path>