jnordberg / wintersmith

A flexible static site generator
http://wintersmith.io/
MIT License
3.5k stars 335 forks source link

quick start guide - wintersmith preview - Cannot find module 'moment' #286

Closed jamshark70 closed 9 years ago

jamshark70 commented 9 years ago

(Yes, I found #264 which looks similar -- however, that issue was closed rapidly. Another user commented with the same error message, but #264 was not reopened. Now I have hit the same problem, so I am opening a new issue to be sure it does not get ignored.)

$ wintersmith new ws
  initializing new wintersmith site in /home/dlm/Documents/web/tests/ws using template blog

(Side note: At this point, the wintersmith process did not exit. I had to kill it with ctrl-c.)

^C
$ cd ws
$ wintersmith preview
  starting preview server
  using config file: /home/dlm/Documents/web/tests/ws/config.json
module.js:338
    throw err;
          ^
Error: Cannot find module 'moment'
    at Function.Module._resolveFilename (module.js:336:15)
    at Function.require.resolve (module.js:388:19)
    at Environment.resolveModule (/usr/local/lib/node_modules/wintersmith/lib/core/environment.js:144:28)
    at Environment.loadModule (/usr/local/lib/node_modules/wintersmith/lib/core/environment.js:242:17)
    at Environment.setupLocals (/usr/local/lib/node_modules/wintersmith/lib/core/environment.js:113:35)
    at Environment.reset (/usr/local/lib/node_modules/wintersmith/lib/core/environment.js:85:19)
    at new Environment (/usr/local/lib/node_modules/wintersmith/lib/core/environment.js:60:12)
    at async.waterfall.paths (/usr/local/lib/node_modules/wintersmith/lib/cli/common.js:104:15)
    at fn (/usr/local/lib/node_modules/wintersmith/node_modules/async/lib/async.js:638:34)
    at Immediate._onImmediate (/usr/local/lib/node_modules/wintersmith/node_modules/async/lib/async.js:554:34)
jamshark70 commented 9 years ago

On a lark, I tried npm -g install moment which got me... another error: "Cannot find module 'underscore'"

Then, "Cannot find module 'typogr'"

And finally the preview server started.

Perhaps the package is missing some dependencies?

At this point, I can continue -- as an aside, it happens that I've had an intensely frustrating few days trying to find a static site generator that suits my needs. This beginning with wintersmith didn't do much to alleviate my frustration.

jamshark70 commented 9 years ago

And now that I start poking around, I see in the example site's config.json:

  "require": {
    "moment": "moment",
    "_": "underscore",
    "typogr": "typogr"
  },

So, either add these as dependencies, or remove them from the sample code, or document in the quick start guide that users need to install them manually to run the example site.

crucialfelix commented 9 years ago

when you first installed wintersmith you had network connectivity issues (related to great wall of china). wintersmith and its dependencies was not properly installed. npm does have a bug/weakness where it doesn't properly check all sub-dependencies when doing an install. If it sees a folder and a package.json then it assumes that package is installed. It doesn't have a command to check if each sub-dep really was installed. solution is to trash node_modules and start again (now that you have switched VPN or used the chinese mirror that the npm people suggested)

wsmith ❯ wintersmith new ws
  initializing new wintersmith site in /Users/crucial/Downloads/wsmith/ws using template blog
typogr@0.5.2 node_modules/typogr

underscore@1.4.4 node_modules/underscore

moment@2.3.1 node_modules/moment
  done!
ws ❯ wintersmith preview
  starting preview server
  using config file: /Users/crucial/Downloads/wsmith/ws/config.json
  server running on: http://localhost:8080/

note: ctrl-c is the correct and normal way to stop a process like a preview server.

crucialfelix commented 9 years ago

btw npm -g install moment this would install it your global ~/node_modules folder. you would want to install it only in the project you are working on. if the folder you are inside has its own node_modules folder then npm install momement would install it there.

but in this case something went wrong with the initial installation of wintersmith and it should have automatically installed ws/package.json it did that for me.

jamshark70 commented 9 years ago

OK, thanks.