thlorenz / browserify-shim

📩 Makes CommonJS incompatible files browserifyable.
MIT License
933 stars 87 forks source link

Unable to find a browserify-shim config section in the package.json (on Linux, but not on Mac OS X) #182

Closed joerixaop closed 8 years ago

joerixaop commented 9 years ago

So I have a project with dependencies on jQuery (added via jquery-rails, and specified in my apps browserify-shim section), d3 and lodash. These last two come from npm, so their source is in the node_modules/ subdirectory

"browserify": {
},
"browser": {
},
"browserify-shim": {
  "jquery": "global:jQuery"
}

When I try to precompile assets on my local development machine (using all the same settings that are used in production) I get the expected output, with lodash and d3 added in the final output. When I run the same command with the same settings on I get the error: Unable to find a browserify-shim config section in the package.json for /projectfolder/shared/node_modules/lodash/index.js while parsing file: /projectfolder/shared/node_modules/lodash/index.js

Modifying /projectfolder/shared/node_modules/lodash/package.json to contain an empty browserify-shim section (and doing the same for d3) works and generates exactly the same file as I get when I generate the file locally, however locally I don't have to modify any npm package. One possible explanation would be a lingering cache from browserify-incremental, but normally I deleted all cache directories, so that shouldn't happen.

Both are tested with browserify-shim 3.8.10 and browserify 10.2.6 (but I had the same issue two weeks ago with browserify-shim 3.8.9 and if I'm not mistaken a slightly older version of browserify).

The command leading to the error is

./node_modules/.bin/browserify -t coffeeify --extension=".js.coffee" --global-transform=browserify-shim -t "./app/assets/javascripts/add_use_strict.js" --list -o "./tmp/cache/browserify-rails/output20150803-40945-x9lvo" -

where the entry javascript file is passed through stdin to the browserify program

bendrucker commented 9 years ago

We really need something that we can run and reproduce to look into this

andrewdelprete commented 9 years ago

+1 I'm getting the same error with a little different setup. After the symlink stuff was merged in Browserify 10.2.6 I started receiving this error with symlinked .coffee files I'm requiring.

bendrucker commented 9 years ago

No +1s needed here please, only a clone-able example or a PR will help us address this.

bendrucker commented 8 years ago

Without a cloneable example we can't proceed