Skip to content

Syntax Error when importing CommonJS module #51

Description

@lmestel

Hi! 👋

Firstly, thanks for your work on this project! 🙂

Today I used patch-package to patch kickstartds@3.0.0 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;

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions