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

Syntax Error when importing CommonJS module #51

Open
lmestel opened this issue Jun 12, 2024 · 0 comments
Open

Syntax Error when importing CommonJS module #51

lmestel opened this issue Jun 12, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@lmestel
Copy link
Contributor

lmestel commented Jun 12, 2024

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch [email protected] for the project I'm working on.

Here is the diff that solved my problem:

diff --git a/node_modules/kickstartds/dist/src/tasks/cms/staticcms-task.js b/node_modules/kickstartds/dist/src/tasks/cms/staticcms-task.js
index 92f61f4..27062ce 100644
--- a/node_modules/kickstartds/dist/src/tasks/cms/staticcms-task.js
+++ b/node_modules/kickstartds/dist/src/tasks/cms/staticcms-task.js
@@ -3,7 +3,8 @@ import { dirname } from 'path';
 import shell from 'shelljs';
 import chalkTemplate from 'chalk-template';
 import createTask from '../task.js';
-import { load as yamlLoad } from 'js-yaml';
+import jsYaml from 'js-yaml';
+const yamlLoad = jsYaml.load;
 const writeFile = fsExtra.writeFile;
 const readFile = fsExtra.readFile;
 const moduleName = 'cms';

This issue body was partially generated by patch-package.

Original Error

import { load as yamlLoad } from 'js-yaml';
         ^^^^
SyntaxError: Named export 'load' not found. The requested module 'js-yaml' 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 'js-yaml';
const { load: yamlLoad } = pkg;
@lmestel lmestel added the bug Something isn't working label Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant