happybeing / svelte-go-wasm-webpack

Quick start template for a Golang WebAssembly app with Svelte front end
GNU General Public License v3.0
10 stars 0 forks source link

Failure to build #1

Open JPL1 opened 3 years ago

JPL1 commented 3 years ago

Following the installation script in the readme fails at yarn && yarn build

user@user:~/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app$ yarn && yarn build
yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 35.90s.
yarn run v1.22.5
$ webpack
Hash: 3ede8e46517da15e5193
Version: webpack 4.44.2
Time: 413ms
Built at: 05/11/2020 20:46:51
        Asset     Size  Chunks                   Chunk Names
    bundle.js  115 KiB  bundle  [emitted]        bundle
bundle.js.map   93 KiB  bundle  [emitted] [dev]  bundle
Entrypoint bundle = bundle.js bundle.js.map
[0] multi ./src/main.js 28 bytes {bundle} [built]
[./node_modules/css-loader/dist/cjs.js!./src/App.svelte.css] 367 bytes {bundle} [built]
[./src/App.svelte] 9.94 KiB {bundle} [built]
[./src/App.svelte.css] 1.07 KiB {bundle} [built]
[./src/NumberInput.svelte] 2.25 KiB {bundle} [built]
[./src/main.go] 308 bytes {bundle} [built] [failed] [1 error]
[./src/main.js] 151 bytes {bundle} [built]
    + 5 hidden modules

ERROR in ./src/main.go
Module build failed (from ../dist/index.js):
Error: spawn undefined/bin/go ENOENT
    at Process.ChildProcess._handle.onexit (internal/child_process.js:269:19)
    at onErrorNT (internal/child_process.js:465:16)
    at processTicksAndRejections (internal/process/task_queues.js:80:21)
 @ ./src/App.svelte 30:0-29 414:40-44
 @ ./src/main.js
 @ multi ./src/main.js
error Command failed with exit code 2.

yarn 1.22.5 node 14.15 Linux Mint 20

happybeing commented 3 years ago

Thanks John, please can you do this and try again:

export GOROOT=`go env GOROOT`
export GOPATH=`go env GOPATH`
JPL1 commented 3 years ago

Same problem I think

user@user:~/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app$ export GOPATH=`go env GOPATH`
user@user:~/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app$ export GOROOT=`go env GOROOT`
user@user:~/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app$ yarn && yarn build
yarn install v1.22.5
[1/4] Resolving packages...
success Already up-to-date.
Done in 0.28s.
yarn run v1.22.5
$ webpack
Hash: 7e49840abbd6b5cce655
Version: webpack 4.44.2
Time: 418ms
Built at: 05/11/2020 23:09:57
        Asset     Size  Chunks                   Chunk Names
    bundle.js  115 KiB  bundle  [emitted]        bundle
bundle.js.map   93 KiB  bundle  [emitted] [dev]  bundle
Entrypoint bundle = bundle.js bundle.js.map
[0] multi ./src/main.js 28 bytes {bundle} [built]
[./node_modules/css-loader/dist/cjs.js!./src/App.svelte.css] 367 bytes {bundle} [built]
[./src/App.svelte] 9.94 KiB {bundle} [built]
[./src/App.svelte.css] 1.07 KiB {bundle} [built]
[./src/NumberInput.svelte] 2.25 KiB {bundle} [built]
[./src/main.go] 748 bytes {bundle} [built] [failed] [1 error]
[./src/main.js] 151 bytes {bundle} [built]
    + 5 hidden modules

ERROR in ./src/main.go
Module build failed (from ../dist/index.js):
Error: Command failed: /usr/lib/go-1.13/bin/go build -o /home/user/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app/src/main.go.wasm /home/user/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app/src/main.go
src/main.go:9:2: cannot find package "." in:
    /home/user/src/wasm_test/webpack-golang-wasm-async-loader/webpack-golang-wasm-async-loader/gobridge

    at ChildProcess.exithandler (child_process.js:303:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1051:16)
    at Socket.<anonymous> (internal/child_process.js:442:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:671:12)
 @ ./src/App.svelte 30:0-29 414:40-44
 @ ./src/main.js
 @ multi ./src/main.js
happybeing commented 3 years ago

Different error now: Error: Command failed: /usr/lib/go-1.13/bin/go build -o /home/user/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app/src/main.go.wasm /home/user/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app/src/main.go src/main.go:9:2: cannot find package "." in: /home/user/src/wasm_test/webpack-golang-wasm-async-loader/webpack-golang-wasm-async-loader/gobridge

Was: Error: spawn undefined/bin/go ENOENT

Will get back to you later. Thanks for this, it's very helpful.

happybeing commented 3 years ago

Hi John,

I see the error is probably because the instructions in the README missed a line and you have your app inside the plugin directory. If that's the issue this should fix it:

mv ~/src/wasm_test/webpack-golang-wasm-async-loader/svelte-go-app ~/src/wasm_test/

Then fingers crossed this will work:

cd ~/src/wasm_test/svelte-go-app
yarn build

If that works you can try it out by:

yarn dev

And opening localhost:5000 (I think) in the browser.

I'll update the README, but if you get a chance to test it let me know if this isn't sorted.

JPL1 commented 3 years ago

Ah. Afraid not. I deleted everything and tried again following the new instructions and it still fails at the same place.

yarn link v1.22.5
success Using linked package for "golang-wasm-async-loader".
Done in 0.03s.
user@user:~/src/wasm_test/svelte-go-app$ yarn && yarn build
yarn install v1.22.5
[1/4] Resolving packages...
[2/4] Fetching packages...
info fsevents@2.1.3: The platform "linux" is incompatible with this module.
info "fsevents@2.1.3" is an optional dependency and failed compatibility check. Excluding it from installation.
info fsevents@1.2.13: The platform "linux" is incompatible with this module.
info "fsevents@1.2.13" is an optional dependency and failed compatibility check. Excluding it from installation.
[3/4] Linking dependencies...
[4/4] Building fresh packages...
Done in 44.74s.
yarn run v1.22.5
$ webpack
Hash: d7d0ae16dd3a7ad736f0
Version: webpack 4.44.2
Time: 424ms
Built at: 09/11/2020 19:30:34
        Asset     Size  Chunks                   Chunk Names
    bundle.js  115 KiB  bundle  [emitted]        bundle
bundle.js.map   93 KiB  bundle  [emitted] [dev]  bundle
Entrypoint bundle = bundle.js bundle.js.map
[0] multi ./src/main.js 28 bytes {bundle} [built]
[./node_modules/css-loader/dist/cjs.js!./src/App.svelte.css] 367 bytes {bundle} [built]
[./src/App.svelte] 9.88 KiB {bundle} [built]
[./src/App.svelte.css] 1.07 KiB {bundle} [built]
[./src/NumberInput.svelte] 2.22 KiB {bundle} [built]
[./src/main.go] 675 bytes {bundle} [built] [failed] [1 error]
[./src/main.js] 151 bytes {bundle} [built]
    + 5 hidden modules

ERROR in ./src/main.go
Module build failed (from ../webpack-golang-wasm-async-loader/dist/index.js):
Error: Command failed: /usr/lib/go-1.13/bin/go build -o -a /home/user/src/wasm_test/svelte-go-app/src/main.go.wasm /home/user/src/wasm_test/svelte-go-app/src/main.go
can't load package: named files must be .go files: /home/user/src/wasm_test/svelte-go-app/src/main.go.wasm

    at ChildProcess.exithandler (child_process.js:303:12)
    at ChildProcess.emit (events.js:315:20)
    at maybeClose (internal/child_process.js:1051:16)
    at Socket.<anonymous> (internal/child_process.js:442:11)
    at Socket.emit (events.js:315:20)
    at Pipe.<anonymous> (net.js:671:12)
 @ ./src/App.svelte 30:0-29 414:40-44
 @ ./src/main.js
 @ multi ./src/main.js
error Command failed with exit code 2.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

After the first yarn link there was a message that a folder was already linked (see below). Could that have anything to do with it? I wasn't sure which dir I should be in.

yarn link v1.22.5
warning There's already a package called "golang-wasm-async-loader" registered. This command has had no effect. If this command was run in another folder with the same name, the other folder is still linked. Please run yarn unlink in the other folder if you want to register this folder.
Done in 0.03s.
user@user:~/src/wasm_test/webpack-golang-wasm-async-loader$ yarn unlink
yarn unlink v1.22.5
success Unregistered "golang-wasm-async-loader".
info You can now run `yarn unlink "golang-wasm-async-loader"` in the projects where you no longer want to use this package.
Done in 0.03s.
user@user:~/src/wasm_test/webpack-golang-wasm-async-loader$ yarn link
yarn link v1.22.5
success Registered "golang-wasm-async-loader".
info You can now run `yarn link "golang-wasm-async-loader"` in the projects where you want to use this package and it will be used instead.
Done in 0.03s.
user@user:~/src/wasm_test/webpack-golang-wasm-async-loader$ 
happybeing commented 3 years ago

Is this Ubuntu?

After the first yarn link there was a message that a folder was already linked (see below). Could that have anything to do with it? I wasn't sure which dir I should be in.

Hmm, I'm not sure that should be a problem. You could try this and see if there are any errors:

cd ~/src/wasm_test/webpack-golang-wasm-async-loader
export GOROOT=`go env GOROOT`
export GOPATH=`go env GOPATH`
yarn build
yarn unlink
yarn link

cd  ~/src/wasm_test/svelte-go-app
yarn unlink golang-wasm-async-loader
yarn link golang-wasm-async-loader

And then in the app try yarn build although I'm not confident that's going to be different!

JPL1 commented 3 years ago

No, same thing. I'm on Mint not Ubuntu, which could be the problem I guess.

happybeing commented 3 years ago

Hmm, I don't think it's an OS issue, I may have screwed something up but can't tell from this.