Skip to content
This repository has been archived by the owner on Oct 4, 2022. It is now read-only.

Published package does not work in a standalone environment #2231

Open
3 of 7 tasks
jcomack opened this issue Nov 27, 2019 · 1 comment
Open
3 of 7 tasks

Published package does not work in a standalone environment #2231

jcomack opened this issue Nov 27, 2019 · 1 comment

Comments

@jcomack
Copy link
Contributor

jcomack commented Nov 27, 2019

What did you expect to happen?

While attempting to implement the Yoast SEO package in a Node.js environment, I expected to be able to run it without errors.

What happened instead?

While attempting to run my own script (i.e. node index.js ), I was presented with the following error:

/Users/theuser/projectdir/node_modules/yoastseo/index.js:1
(function (exports, require, module, __filename, __dirname) { import { AnalysisWebWorker, AnalysisWorkerWrapper, createWorker } from "./src/worker";

SyntaxError: Unexpected token {

Please note: This issue occurs because the index.js file in the package does not get Bablified, but it should.

How can we reproduce this behavior?

  • Create an empty, standalone environment in a new directory.
  • Run yarn init and go through all the steps.
  • Run yarn add yoastseo.
  • Create a new file in the directory named index.js and paste the following code in the file:
// Altered the import to this to ensure compatibility with Node.
const { Paper, Researcher } = require( "yoastseo" );

const paper = new Paper( "Text to analyze", {
	keyword: "analyze",
} );
const researcher = new Researcher( paper );

console.log( researcher.getResearch( "wordCountInText" ) );
  • Run node index.js.
  • See error appear.

Technical info

  • Platform: Standalone
  • Platform version:
  • Yoast SEO version: 1.64.0

Which browser is affected (or browsers):

  • Chrome
  • Firefox
  • Safari
  • Other

If relevant, which editor is affected (or editors):

  • Classic Editor
  • Gutenberg
  • Classic Editor plugin
@orasik
Copy link

orasik commented Mar 10, 2021

I have the same issue, did you find a solution? @jcomack

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

No branches or pull requests

2 participants