Skip to content

Packaging issues after node-jquery update #54

Closed

Description

@miffels

Hi sokra,

I just got involved in another JS project and decided to stick with the tools I am familiar with, i.e. webpack, among others. Unfortunately when I created a new project I ran into some strange errors I could not explain. I ended up cleaning my old project of all generated content (npm & jam modules) and updated the dependencies. Now with node-jquery 1.8.3 my old project won't build at all. When I try to webpack the following minimal example

// main.js
'use strict';

/*global require:true */
require = require('enhanced-require')(module, {
    recursive: true
});

var $ = require('jquery');

I get the following warnings:

WARNING: A file in context was excluded because of error: Error: File "<project root>\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level1\core.js" parsing failed: Error: Line 418: Unexpected token )
WARNING: A file in context was excluded because of error: Error: File "<project root>\node_modules\jquery\node_mod
ules\jsdom\lib\jsdom\level2\html.js" parsing failed: Error: Line 446: Unexpected token )
WARNING: Cannot find module 'node-htmlparser/lib/node-htmlparser'
 Error: Module "node-htmlparser/lib/node-htmlparser" not found in context "<project root>\node_modules\jquery\node
_modules\jsdom\lib\jsdom\browser"
  Error: <project root>\node_modules\webpack\buildin\node-htmlparser\lib\node-htmlparser is not a directory
 @ <project root>\node_modules\jquery\node_modules\jsdom\lib\jsdom\browser\index.js (line 336, column 24)
WARNING: Cannot find module 'tls'
 Error: Module "tls" not found in context "<project root>\node_modules\jquery\node_modules\jsdom\node_modules\requ
est"
  Error: Non of this files exists: <project root>\node_modules\webpack\buildin\tls-webpack, <project root>
\node_modules\webpack\buildin\tls-webpack.webpack.js, <project root>
\node_modules\webpack\buildin\tls-webpack.web.js, <project root>\node_modules\webpack\buildin\tls-webpack.js
 @ <project root>\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 44, column 8)
WARNING: A file in context was excluded because of error: Error: File "<project root>\node_modules\jquery\node_mod
ules\contextify\node_modules\bindings\README.md" parsing failed: Error: Line 2: Unexpected token ===
WARNING: Cannot find module 'https'
 Error: Module "https" not found in context "<project root>\node_modules\jquery\node_modules\jsdom\node_modules\re
quest"
  Error: Non of this files exists: <project root>\node_modules\webpack\buildin\https, <project root>
\node_modules\webpack\buildin\https.webpack.js, <project root>\node_module
s\webpack\buildin\https.web.js, <project root>\node_modules\webpack\buildin\https.js
 @ <project root>\node_modules\jquery\node_modules\jsdom\node_modules\request\main.js (line 40, column 10)

plus a ton of errors like:

ERROR: Cannot find module '../../../lib/numeric'
 Error: Error: Module "jshint" not found in context "<project root>\src\client\numeric"
  Error: <project root>\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
 @ <project root>\src\client\numeric\LinearSolver.js (line 7, column 36)
ERROR: Cannot find module '../../../../lib/spin'
 Error: Error: Module "jshint" not found in context "<project root>\src\client\view\recipe"
  Error: <project root>\node_modules\webpack\buildin\jshint-webpack-loader is not a directory
 @ <project root>\src\client\view\recipe\RecipeListView.js (line 9, column 11)
ERROR: Cannot find module 'fs'
 Error: Module "fs" not found in context "<project root>\node_modules\jquery\node_modules\xmlhttprequest\lib"
  Error: <project root>\node_modules\webpack\buildin\fs is not a directory
 @ <project root>\node_modules\jquery\node_modules\xmlhttprequest\lib\XMLHttpRequest.js (line 16, column 9)

For this example I npm installed the latest versions of jquery, webpack, enhanced-require (node_modules) and jam installed jquery (web_modules). Do you happen to have an idea of what went wrong here?

Activity

  1. miffels commented on Jan 20, 2013

    @miffels
    Author

    I just played around a bit more and got the following results:

    webpack 0.8.x plays nicely with enhanced-require 0.4.x, node-jquery 1.7.x and (jam) jquery 1.7.x. Updating node-jquery to the latest version (1.8.3) did not change anything (i.e. it still built flawlessly). When I did the same with jam's jquery, though, the above errors reoccured (tried 1.9.0pre and 1.8.3). I actually suspected node-jquery to cause the errors, so that outcome sort of surprised me.

  2. sokra commented on Jan 21, 2013

    @sokra
    Member

    hmm.. i think the problem is that webpack do not respect the jam section in the package.json

      "jam": {
        "main": "dist/jquery.js",
        "include": ["dist/jquery.js"]
      }

    So it tries to load index.js which doesn't exist. So it tries node-jquery with mixed in jam's jquery... fail...

    I'll add support for jam.main as packageMains.


    jam writes a config for require.js which includes the main field. So require.js would work.

  3. sokra commented on Jan 21, 2013

    @sokra
    Member

    So I added jam.main to the defaults for packageMains.

    Your example will build now:

    Hash: 434aa3aa5292c1b194270b7b7657b191
    Compile Time: 554ms
    Chunks: 1
    Modules: 7
    Modules including duplicates: 7
    Modules first chunk: 7
    main   bundle.js:   272884 chars/bytes
    
     <id>    <size>  <filename>
    bundle.js
        0       134  .\main.js
        1       445  (webpack)\buildin\__webpack_amd_require.js
        2       552  (webpack)\buildin\__webpack_amd_define.js
        3       251  (webpack)\buildin\__webpack_module.js
        4        24  (webpack)\buildin\__webpack_options_amd.loader.js!(webpack)\buildin\__webpack_options_amd.loader.js
        5       151  (webpack)\~\enhanced-require\lib\require.webpack.js
        6    269754  .\web_modules\jquery\dist\jquery.js
    
  4. miffels commented on Jan 22, 2013

    @miffels
    Author

    Hi sokra,

    I just tried it in one of my projects and can confirm this works flawlessly. Thank you very much!

    Best regards,
    miffels

  5. sokra commented on Jan 22, 2013

    @sokra
    Member

    😄

  6. added a commit that references this issue on Apr 13, 2026
    e42701d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Fields

    Priority

    None yet

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions