Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Migration to Svelte 4 fails if a project doesn’t have dependencies #10220

Closed
malinowskip opened this issue Jun 22, 2023 · 1 comment · Fixed by #10221
Closed

Migration to Svelte 4 fails if a project doesn’t have dependencies #10220

malinowskip opened this issue Jun 22, 2023 · 1 comment · Fixed by #10221

Comments

@malinowskip
Copy link
Contributor

Describe the bug

Migration to Svelte 4 using svelte-migrate fails if the project’s package.json doesn’t have dependencies. The error occurs here (the script attempts to read the package name on undefined):

if (pkg.dependencies[name]) {

Reproduction

Run npx svelte-migrate svelte-4 in a project that does not have dependencies in its package.json.

Logs

file:///Users/pm/.npm/_npx/ca732f115159e57c/node_modules/svelte-migrate/migrations/svelte-4/migrate.js:24
		if (pkg.dependencies[name]) {
		                    ^

TypeError: Cannot read properties of undefined (reading 'svelte')
    at update_pkg (file:///Users/pm/.npm/_npx/ca732f115159e57c/node_modules/svelte-migrate/migrations/svelte-4/migrate.js:24:23)
    at update_pkg_json_content (file:///Users/pm/.npm/_npx/ca732f115159e57c/node_modules/svelte-migrate/migrations/svelte-4/migrate.js:34:2)
    at update_pkg_json (file:///Users/pm/.npm/_npx/ca732f115159e57c/node_modules/svelte-migrate/migrations/svelte-4/migrate.js:7:3)
    at migrate (file:///Users/pm/.npm/_npx/ca732f115159e57c/node_modules/svelte-migrate/migrations/svelte-4/index.js:59:2)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)

System Info

System:
    OS: macOS 13.4
    CPU: (8) arm64 Apple M1
    Memory: 85.78 MB / 16.00 GB
    Shell: 3.6.1 - /opt/homebrew/bin/fish
  Binaries:
    Node: 20.3.0 - /opt/homebrew/bin/node
    Yarn: 1.22.19 - /opt/homebrew/bin/yarn
    npm: 9.6.7 - /opt/homebrew/bin/npm
  Browsers:
    Chrome: 114.0.5735.133
    Edge: 114.0.1823.37
    Safari: 16.5
  npmPackages:
    @sveltejs/adapter-auto: 1.0.0-next.90 => 1.0.0-next.90
    @sveltejs/adapter-static: 1.0.0-next.49 => 1.0.0-next.49
    @sveltejs/kit: ^1.20.4 => 1.20.4
    svelte: ^3.59.2 => 3.59.2
    vite: ^4.3.9 => 4.3.9

Severity

blocking an upgrade

Additional Information

No response

@gtm-nayan
Copy link
Contributor

gtm-nayan commented Jun 22, 2023

Released in [email protected], you might want to specify the version number when running again to avoid any caching

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants