Kenny Ki
Kenny Ki

Reputation: 3430

Command "docpad run" is getting error: "module" is undefined

I've migrated my configurations from docpad.coffee to docpad.js (personal preference on using plain Javascript)

Since then, I'm not being able to execute the command

docpad run

And I'm keep getting this error:

error

I've validated my configurations against JSLint and made sure there's no syntax error.

I'm good to go with docpad.coffee, but it'd be great if someone could help me on fixing this

Upvotes: 1

Views: 515

Answers (2)

Wolfgang Kluge
Wolfgang Kluge

Reputation: 895

You can use docpad.cmd run instead of docpad run to distinguish between the local docpad.js and the global npm-installed docpad.cmd.

Upvotes: 2

Steve Mc
Steve Mc

Reputation: 3441

This is because windows recognises the ".js" extension as a javascript file and tries to run your docpad.js file when you issue the "docpad run" command. Windows script host is what is used by windows to run js files natively (so actually nothing to do with node or docpad itself). The reference to "module" in the error message is because that is the first line of the docpad.js file and the windows script host doesn't know what "module" is. You can just rename your docpad.js file to .coffee (I believe all javascript is valid coffee script) and then the windows message will disappear.

Edit: I've just went and tested this on the docpad skeleton which has a docpad.js file instead of docpad.coffee. Simply renaming it to docpad.coffee does indeed solve the problem. Renaming it back to .js then causes the 'Windows Script Host' error message to appear when the "docpad run" command is issued.

Upvotes: 2

Related Questions