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

devalue import fails with adapter-node #6394

Closed
DrDanRyan opened this issue Aug 29, 2022 · 8 comments
Closed

devalue import fails with adapter-node #6394

DrDanRyan opened this issue Aug 29, 2022 · 8 comments

Comments

@DrDanRyan
Copy link

Describe the bug

Had to change the line in build/server/index.js from

import { devalue } from "devalue"

to

import devalue from "devalue

to get my app to start after updating to @sveltejs/kit version "1.0.0-next.448" and @sveltejs/adapter-node version "1.0.0-next.87"

Reproduction

Build an app with standard adapter-node server and start with node build/index.js

Logs

SyntaxError: Named export 'devalue' not found. The requested module 'devalue' is a CommonJS module, which may not support all module.exports as named exports.
 CommonJS modules can always be imported via the default export, for example using:

 import pkg from 'devalue';
 const { devalue } = pkg;

     at ModuleJob._instantiate (node:internal/modules/esm/module_job:128:21)
     at async ModuleJob.run (node:internal/modules/esm/module_job:194:5)
     at async Promise.all (index 0)
     at async ESMLoader.import (node:internal/modules/esm/loader:385:24)
     at async importModuleDynamicallyWrapper (node:internal/vm/module:437:15)

System Info

@sveltejs/kit version "1.0.0-next.448"
@sveltejs/adapter-node version "1.0.0-next.87"

Severity

serious, but I can work around it

Additional Information

Easy workaround but, if user is not aware it will block them from deployment. Also the error message solution of changing to

import pkg from "devalue";
const { devalue } = pkg;

fails. Instead you need to do import devalue from "devalue".

@Conduitry
Copy link
Member

It doesn't sound like you upgraded from devalue 2 to 3 (which could also mean you're using one of the workarounds in #3176 where you add devalue as a direct dependency to your project, which you then did not upgrade). That should all be unnecessary soon anyway with #6372.

@DrDanRyan DrDanRyan changed the title adapter-node devalue import fails with adapter-node Aug 29, 2022
@DrDanRyan
Copy link
Author

On first deploy it complained about "cannot find package devalue", and then I remembered that I had to do the workaround of installing it. I copied the package.json lines out of my other project with the workaround, and you are correct it was version 2 of devalue.

I guess the real issue is that it did not find a devalue package installed after the initial build step.

@Conduitry
Copy link
Member

Are you still seeing this with the latest versions of everything? If so, please provide a minimal reproduction as a clonable repo.

@benmccann
Copy link
Member

This is fixed with the latest version

@DrDanRyan
Copy link
Author

Newest version fixes everything. Thank you! Btw, the new and improved dependency bundling is really sweet!

@jesperordrup
Copy link

jesperordrup commented Aug 31, 2022

I have the same problem.

can anyone tell which version introduced this problem? I need to go back to before that. Cant go forward as I get other issues

@john-nhoj
Copy link

I have the same problem.

can anyone tell which version introduced this problem? I need to go back to before that. Cant go forward as I get other issues

Hi @jesperordrup , I am facing the same issue and was able to make it work with "@sveltejs/kit": "1.0.0-next.445",

@DrDanRyan
Copy link
Author

DrDanRyan commented Aug 31, 2022

I have the same problem.

can anyone tell which version introduced this problem? I need to go back to before that. Cant go forward as I get other issues

It sounds like you might be able to solve it by installing devalue version 3 as a production dependency.

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

No branches or pull requests

5 participants