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

"npm init wasm-app www" doesn't produce a www-directory #34

Closed
kawogi opened this issue Aug 29, 2018 · 11 comments
Closed

"npm init wasm-app www" doesn't produce a www-directory #34

kawogi opened this issue Aug 29, 2018 · 11 comments

Comments

@kawogi
Copy link

kawogi commented Aug 29, 2018

I'm a total noob regarding npm and tried to blindy follow the tutorial:

In the chapter https://rustwasm.github.io/book/game-of-life/hello-world.html#putting-it-into-a-web-page one has to issue npm init wasm-app www

This command asks me some questions and quits after creating a package.json:

$ npm init wasm-app www
This utility will walk you through creating a package.json file.
It only covers the most common items, and tries to guess sensible defaults.

See `npm help json` for definitive documentation on these fields
and exactly what they do.

Use `npm install <pkg> --save` afterwards to install a package and
save it as a dependency in the package.json file.

Press ^C at any time to quit.
name: (wasm-game-of-life) 
version: (1.0.0) 
git repository: 
keywords: 
author: 
license: (ISC) 
About to write to /home/kai/dev/wasm-game-of-life/package.json:

{
  "name": "wasm-game-of-life",
  "version": "1.0.0",
  "description": "a template for starting a rust-wasm project to be used with wasm-pack",
  "main": "index.js",
  "scripts": {
    "test": "echo \"Error: no test specified\" && exit 1"
  },
  "author": "",
  "license": "ISC"
}


Is this ok? (yes)

According to the documentation of npm this seems to be correct, but doesn't behave as expected according to the tutorial. There's no www-directory.

Did I oversee something in the prerequisites or do I have some wrong npm?

npm version outputs

{ 'wasm-game-of-life': '1.0.0',
  npm: '3.5.2',
  ares: '1.14.0',
  cldr: '32.0.1',
  http_parser: '2.7.1',
  icu: '60.2',
  modules: '57',
  nghttp2: '1.30.0',
  node: '8.10.0',
  openssl: '1.1.0g',
  tz: '2017c',
  unicode: '10.0',
  uv: '1.18.0',
  v8: '6.2.414.50',
  zlib: '1.2.11' }
@fitzgen
Copy link
Member

fitzgen commented Aug 29, 2018

What version of node and npm do you have? The npm init wasm-app command should be downloading and running create-wasm-app, not going through the default npm init stuff that it appears to be doing.

We had a similar issue earlier today, but that was fixed by a new release of create-wasm-app -- have you tried this in the last 3 hours?

@kawogi
Copy link
Author

kawogi commented Aug 31, 2018

node.js is v8.10.0
npm is v3.5.2
Which steps would I have to retry? I re-started from wasm-pack init which seems to succeed.

@fitzgen
Copy link
Member

fitzgen commented Aug 31, 2018

So npm init wasm-app www is working for you now? If so, I suspect it was the same issue that got fixed earlier that day.

Going to close this issue then, but if I misunderstand, let me know and we can reopen!

@fitzgen fitzgen closed this as completed Aug 31, 2018
@kawogi
Copy link
Author

kawogi commented Sep 1, 2018

Sorry for the confusion - I should have re-read my previous post. wasm-pack init still succeeds, but npm init wasm-app www still doesn't work as expected.
Do I have to delete some of the generated files?

@fitzgen
Copy link
Member

fitzgen commented Sep 4, 2018

Do I have to delete some of the generated files?

Most likely you have to delete the www directory. Let me know if that works

@kawogi
Copy link
Author

kawogi commented Sep 4, 2018

As mentioned before: there's no such directory.

The manpage for npm init states: npm init [-f|--force|-y|--yes] which doesn't comply with the command line given in the tutorial.

I still think I got something very basic wrong.

@fitzgen
Copy link
Member

fitzgen commented Sep 4, 2018

It is documented here: https://docs.npmjs.com/cli/init#description

npm init can be used to set up a new or existing npm package.

initializer in this case is an npm package named create-, which will be installed by npx, and then have its main bin executed -- presumably creating or updating package.json and running any other initialization-related operations.

The init command is transformed to a corresponding npx operation as follows:

npm init foo -> npx create-foo
npm init @usr/foo -> npx @usr/create-foo
npm init @usr -> npx @usr/create

Any additional options will be passed directly to the command, so npm init foo --hello will map to npx create-foo --hello.


npm is v3.5.2

perhaps this is the issue; try running npm install npm@latest -g

@kawogi
Copy link
Author

kawogi commented Sep 4, 2018

The update seems to succeed, but the version remains the same:

$ nodejs -v
v8.10.0
$ npm -v
3.5.2

Can you tell me the minimum version required to pass the tutorial? Or maybe just the version you would have expected after the update?

Update: I had to re-open the terminal - duh! The versions are now:

$ npm -v
6.4.1
$ npm init wasm-app www
npx: installed 1 in 2.24s
🦀 Rust + 🕸 Wasm = ❤

This issue can be closed, but maybe a hint for a minimum version would be helpful. I simply relied on the packaged version in my distribution.
Thanks for your help!

@ps-account
Copy link

I had exactly the same issue and following the comments above (indeed including re-opening the terminal) solved it!

@nooberfsh
Copy link

I have the same issue.
node: v12.1.0
npm: 5.0.0
os: macOS Mojave version 10.14

@wiaxr
Copy link

wiaxr commented Jun 18, 2020

rustwasm/create-wasm-app#143 (comment)

Try this patch .bin -> ./bin for the create-wasm-app.

diff --git a/.bin/create-wasm-app.js b/bin/create-wasm-app.js
similarity index 100%
rename from .bin/create-wasm-app.js
rename to bin/create-wasm-app.js
diff --git a/package.json b/package.json
index d21d358..1731e4f 100644
--- a/package.json
+++ b/package.json
@@ -4,7 +4,7 @@
   "description": "create an app to consume rust-generated wasm packages",
   "main": "index.js",
   "bin": {
-    "create-wasm-app": ".bin/create-wasm-app.js"
+    "create-wasm-app": "./bin/create-wasm-app.js"
   },
   "scripts": {
     "build": "webpack --config webpack.config.js",

It must create the link:

ls -l  ~/.yarn/bin
ls -l $(yarn global bin)
lrwxrwxrwx ... create-wasm-app -> ../../.config/yarn/global/node_modules/.bin/create-wasm-app

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

5 participants