Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

3.0.3 not working with browserify #6

Open
rhodey opened this issue Nov 16, 2020 · 8 comments
Open

3.0.3 not working with browserify #6

rhodey opened this issue Nov 16, 2020 · 8 comments

Comments

@rhodey
Copy link

rhodey commented Nov 16, 2020

Hello, I am running into this issue while trying to bundle hypercore for a web app. I have put together a minimal example project that fails to bundle with browserify. I have been trying to fix this myself but am not well experienced with browserify. Any help would be greatly appreciated, thank you.

https://github.com/rhodey/sodium-debug

> Error: Can't walk dependency graph: Cannot find module './crypto_auth' from '/home/rhodey/dev/dsp/js/sodium-debug/node_modules/sodium-universal/index.js'
    required by /home/rhodey/dev/dsp/js/sodium-debug/node_modules/sodium-universal/index.js
        at /home/rhodey/.nvm/versions/node/v14.13.1/lib/node_modules/browserify/node_modules/resolve/lib/async.js:137:35
	    at load (/home/rhodey/.nvm/versions/node/v14.13.1/lib/node_modules/browserify/node_modules/resolve/lib/async.js:156:43)
	        at onex (/home/rhodey/.nvm/versions/node/v14.13.1/lib/node_modules/browserify/node_modules/resolve/lib/async.js:181:17)
		    at /home/rhodey/.nvm/versions/node/v14.13.1/lib/node_modules/browserify/node_modules/resolve/lib/async.js:15:69
		        at FSReqCallback.oncomplete (fs.js:181:21)

@rhodey rhodey changed the title Cannot find module './crypto_auth' not working with browserify Nov 16, 2020
@rhodey rhodey changed the title not working with browserify 3.0.3 not working with browserify Nov 16, 2020
@rhodey
Copy link
Author

rhodey commented Nov 16, 2020

Update: I switched my example to use v3.0.2 and the error went away, appears to be an issue introduced in 3.0.3

@paul90
Copy link

paul90 commented Dec 17, 2020

A couple of days ago I had the same problem, with Cannot find module './crypto_auth'.

Looking a little deeper, and comparing the contents of the v3.0.3 package from npm, and cloning this project's repo locally. It looks very much as if the prepublish script didn't get run before the package was published. At least manually running it creates ./crypto_auth.js, and the package can be installed locally using npm i $(npm pack ../sodium-universal | tail -1) and not get that error.

@RangerMauve
Copy link

Also running into this.

@4c656554
Copy link

4c656554 commented Jan 3, 2021

Me too. I think it originates with this commit, to sodium-javascript:

sodium-friends/sodium-javascript@656d6d2

and this one in sodium-universal:

e97357e

@4c656554
Copy link

4c656554 commented Jan 3, 2021

A couple of days ago I had the same problem, with Cannot find module './crypto_auth'.

Looking a little deeper, and comparing the contents of the v3.0.3 package from npm, and cloning this project's repo locally. It looks very much as if the prepublish script didn't get run before the package was published. At least manually running it creates ./crypto_auth.js, and the package can be installed locally using npm i $(npm pack ../sodium-universal | tail -1) and not get that error.

Forgive me, where is the prepublish script, and when should it normally be run? During build?

@paul90
Copy link

paul90 commented Jan 3, 2021

The prepublish script is defined in package.json.

"prepublish": "./build-scripts/generate.js"

It should be noted that the prepublish script was deprecated in npm@5 and running npm install in the cloned repo gives the warning:

npm WARN prepublish-on-install As of npm@5, `prepublish` scripts are deprecated.
npm WARN prepublish-on-install Use `prepare` for build steps and `prepublishOnly` for upload-only.
npm WARN prepublish-on-install See the deprecation note in `npm help scripts` for more information.

With the version of npm that comes with Node 14.15.1, npm 6.14.9, it looks as prepublish is treated as if it was prepare. But, I see some comments that indicate that this might not have been the case with some versions of npm@6

@4c656554
Copy link

4c656554 commented Jan 3, 2021

Thanks to @paul90, I solved it like this.

Note I am not experienced at building node projects so perhaps this will break something somewhere else. But it worked for me:

  1. cd into the yourPath/node_modules/sodium-universal/build-scripts dir
  2. run node generate.js
  3. go back to your parent module and build as normal

@paul90
Copy link

paul90 commented Feb 15, 2021

The release of sodium-universal@3.0.4 should have resolved this issue.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants