javascript icon indicating copy to clipboard operation
javascript copied to clipboard

Install yoast with npm and then run it in nodejs

Open HappyLDE opened this issue 5 years ago • 4 comments

Explanation

I'm trying to get Yoast to work in a nodejs app, so I installed it following these steps (node v12.13.0):

  • In an empty folder I opened the terminal and typed: npm install yoastseo

  • Result:

npm WARN saveError ENOENT: no such file or directory, open '/home/bringw/www/first-app/package.json'
npm WARN enoent ENOENT: no such file or directory, open '/home/bringw/www/first-app/package.json'
npm WARN first-app No description
npm WARN first-app No repository field.
npm WARN first-app No README data
npm WARN first-app No license field.

+ [email protected]
added 22 packages from 16 contributors and audited 1713 packages in 3.676s
found 0 vulnerabilities
  • Next I created an empty file named app.js an pasted the following code (from the homepage):
import { AnalysisWebWorker } from "yoastseo";

const worker = new AnalysisWebWorker( self );
worker.register();
  • Then run the file with node like follows: node app.js

  • And the result:

/home/bringw/www/first-app/app.js:1
import { AnalysisWebWorker } from "yoastseo";
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at Module._compile (internal/modules/cjs/loader.js:892:18)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:973:10)
    at Module.load (internal/modules/cjs/loader.js:812:32)
    at Function.Module._load (internal/modules/cjs/loader.js:724:14)
    at Function.Module.runMain (internal/modules/cjs/loader.js:1025:10)
    at internal/main/run_main_module.js:17:11

Edit Also if I run: npm test

I get:

npm ERR! code ENOENT
npm ERR! syscall open
npm ERR! path /home/bringw/www/first-app/package.json
npm ERR! errno -2
npm ERR! enoent ENOENT: no such file or directory, open '/home/bringw/www/first-app/package.json'
npm ERR! enoent This is related to npm not being able to find a file.
npm ERR! enoent 

npm ERR! A complete log of this run can be found in:
npm ERR!     /home/bringw/.npm/_logs/2019-10-28T08_51_34_042Z-debug.log

Feedback?

The documentation is lacking seriously, there is no guide or anything, what are we supposed to do? :(

Thank you :D

HappyLDE avatar Oct 28 '19 08:10 HappyLDE

Hello, i'm also stuck on this... Do you have any progress?

Cool-Programmer avatar Jan 19 '20 15:01 Cool-Programmer

Hello, i'm also stuck on this... Do you have any progress?

Still no progress since i dont have experience with nodejs

HappyLDE avatar Jan 19 '20 16:01 HappyLDE

I'm kind of progressing through it. But unable to generate the report... so I'm sort of creating my own report given the data.

aomini avatar Oct 11 '20 07:10 aomini

Hello, any update on this. we are waiting since long time. Feel this is very nice package, but struck due to this issue. till version 1.22.4 works in nodejs project. after that it broken.

asokb4u avatar Apr 01 '21 08:04 asokb4u