0

The outdated documentation for drupal integration of nodejs using the nodejs module instructs me to start nodejs with the command node server.js.

But neither server.js or app.js (replacement to server.js) exists

I can see a file called nodejs.js but running node nodejs.js produces this error;

ReferenceError: jQuery is not defined
    at Object.<anonymous> (/data/disk/o1/static/hood-7.43.1/sites/all/modules/nodejs/nodejs.js:132:4)
    at Module._compile (module.js:460:26)
    at Object.Module._extensions..js (module.js:478:10)
    at Module.load (module.js:355:32)
    at Function.Module._load (module.js:310:12)
    at Function.Module.runMain (module.js:501:10)
    at startup (node.js:129:16)
    at node.js:814:3

What is the command for starting nodejs?

2
  • What is the command for starting nodejs? it's node server.js
    – No Sssweat
    May 14, 2016 at 10:56
  • Follow this for Drupal 8 OR for Drupal 7. They are different, so make sure you follow the correct version.
    – No Sssweat
    May 14, 2016 at 10:58

2 Answers 2

1

If you're downloading the app from github directly, follow these instructions:

  1. Download the archive
  2. Extract to a folder oustide of Drupal's root (this app is separate to your Drupal installation so shouldn't be within)
  3. cd to the folder and run npm install
  4. Run cp nodejs.config.js.example nodejs.config.js, edit the resulting file as required
  5. Run node app.js

Voila, server up and running.

If you're using the npm install drupal-node.js approach, the instructions are a bit unclear. To clarify:

  1. Create a folder outside of the Drupal root
  2. cd to it and run npm install drupal-node.js
  3. Run cp node_modules/drupal-node.js/nodejs.config.js.example nodejs.config.js, edit as required
  4. Run node node_modules/drupal-node.js/app.js to start the server

You should see the same result as the first method.

4
  • app.js does not exist and neither does the node node_modules/drupal-node.js/app.js path
    – Meggy
    May 15, 2016 at 20:44
  • I tried both of those methods, they both work fine. You might need to start again from scratch
    – Clive
    May 15, 2016 at 20:52
  • I'm using the "forever" keep alive startup service. Would that change things at all?
    – Meggy
    May 16, 2016 at 10:02
  • Shouldn't do, but consult the docs just in case
    – Clive
    May 16, 2016 at 10:05
0

Turns out I had incorrectly upgraded the 7.x-1.10 module incorrectly. From version 7.x-1.1 you can no longer merely overwrite the old module with the new module as the installation process is different.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.