rubyonjets / jets

Ruby on Jets
http://rubyonjets.com
MIT License
2.6k stars 181 forks source link

package.json not being created on `jets new` #187

Closed tsabat closed 5 years ago

tsabat commented 5 years ago

Checklist

My Environment

Software Version
Operating System osx
Jets latest
Ruby 2.5+

Expected Behaviour

When i run

jets new demo --database=postgresql; cd demo; jets generate scaffold Post title:string body:text published:boolean; jets db:create db:migrate; jets server --port 9977 --host 0.0.0.0

I'd expect a package.json to be created. It is not. This example project has one that's created on the "first commit".

Current Behavior

jets skips the package.json creation.

Creating new project called demo.
      create  demo
      create  demo/.env.development
      create  demo/.env.test
      create  demo/.env
      create  demo/.gitignore
      create  demo/.jetskeep
      create  demo/.rspec
      create  demo/Gemfile
      create  demo/Procfile
      create  demo/README.md
      create  demo/Rakefile
      create  demo/app/controllers/application_controller.rb
      create  demo/app/helpers/application_helper.rb
      create  demo/app/jobs/application_job.rb
      create  demo/app/models/application_item.rb
      create  demo/app/models/application_record.rb
      create  demo/app/views/layouts/application.html.erb
      create  demo/config.ru
      create  demo/config/application.rb
      create  demo/config/database.yml
      create  demo/config/dynamodb.yml
      create  demo/config/environments/development.rb
      create  demo/config/environments/production.rb
      create  demo/config/routes.rb
      create  demo/db/.gitkeep
      create  demo/public/404.html
      create  demo/public/422.html
      create  demo/public/500.html
      create  demo/public/favicon.ico
      create  demo/public/index.html
      create  demo/spec/controllers/posts_controller_spec.rb
      create  demo/spec/fixtures/payloads/posts-index.json
      create  demo/spec/fixtures/payloads/posts-show.json
      create  demo/spec/spec_helper.rb
Fetching https://github.com/tongueroo/webpacker.git
Fetching gem metadata from https://rubygems.org/........
Resolving dependencies...
Using rake 12.3.2
Using concurrent-ruby 1.1.4
Using i18n 1.5.3
Using minitest 5.11.3
Using thread_safe 0.3.6
Using tzinfo 1.2.5
Using activesupport 5.2.2
Using builder 3.2.3
Using erubi 1.8.0
Using mini_portile2 2.4.0
Using nokogiri 1.10.1
Using rails-dom-testing 2.0.3
Using crass 1.0.4
Using loofah 2.2.3
Using rails-html-sanitizer 1.0.4
Using actionview 5.2.2
Using rack 2.0.6
Using rack-test 1.1.0
Using actionpack 5.2.2
Using activemodel 5.2.2
Using arel 9.0.0
Using activerecord 5.2.2
Using public_suffix 3.0.3
Using addressable 2.6.0
Using aws-eventstream 1.0.1
Using aws-partitions 1.136.0
Using aws-sigv4 1.0.3
Using jmespath 1.4.0
Using aws-sdk-core 3.46.0
Using aws-sdk-apigateway 1.23.0
Using aws-sdk-cloudformation 1.14.0
Using aws-sdk-cloudwatchlogs 1.13.0
Using aws-sdk-dynamodb 1.20.0
Using aws-sdk-kms 1.13.0
Using aws-sdk-lambda 1.17.0
Using aws-sdk-s3 1.30.1
Using aws-sdk-sns 1.9.0
Using aws-sdk-sqs 1.10.0
Using bundler 2.0.1
Using byebug 10.0.2
Using mini_mime 1.0.1
Using regexp_parser 1.3.0
Using xpath 3.2.0
Using capybara 3.13.2
Using diff-lcs 1.3
Using dotenv 2.6.0
Using dynomite 1.2.2
Using json 2.1.0
Using gems 1.1.1
Using hashie 3.6.0
Using jets-html-sanitizer 1.0.4
Using kramdown 2.1.0
Using memoist 0.16.0
Using mimemagic 0.3.3
Using method_source 0.9.2
Using thor 0.20.3
Using railties 5.2.2
Using rainbow 3.0.0
Using recursive-open-struct 1.1.0
Using text-table 1.2.4
Using jets 1.6.9
Using launchy 2.4.3
Using pg 1.1.4
Using rack-proxy 0.6.5
Using rspec-support 3.8.0
Using rspec-core 3.8.0
Using rspec-expectations 3.8.2
Using rspec-mocks 3.8.0
Using rspec 3.8.0
Using shotgun 0.9.2
Using webpacker 3.2.0 from https://github.com/tongueroo/webpacker.git (at jets@3651cc3)
Bundle complete! 10 Gemfile dependencies, 71 gems now installed.
Use `bundle info [gemname]` to see where a bundled gem is installed.
         run  jets webpacker:install from "."
      create  config/webpacker.yml
Copying webpack core config
      create  config/webpack
      create  config/webpack/development.js
      create  config/webpack/environment.js
      create  config/webpack/production.js
      create  config/webpack/staging.js
      create  config/webpack/test.js
Copying .postcssrc.yml to app root directory
      create  .postcssrc.yml
Copying .babelrc to app root directory
      create  .babelrc
Installing binstubs
         run  bundle binstubs webpacker from "."
      append  .gitignore
Installing all JavaScript dependencies
         run  yarn add @rails/webpacker coffeescript@1.12.7 from "."
yarn add v1.13.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
warning " > webpack-dev-server@3.1.14" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.4.0" has unmet peer dependency "webpack@^4.0.0".
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
[4/4] πŸ”¨  Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ @rails/webpacker@3.5.5
info All dependencies
└─ @rails/webpacker@3.5.5
✨  Done in 2.90s.
Installing dev server for live reloading
         run  yarn add --dev webpack-dev-server from "."
yarn add v1.13.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning "webpack-dev-server > webpack-dev-middleware@3.4.0" has unmet peer dependency "webpack@^4.0.0".
warning " > webpack-dev-server@3.1.14" has unmet peer dependency "webpack@^4.0.0".
[4/4] πŸ”¨  Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ webpack-dev-server@3.1.14
info All dependencies
└─ webpack-dev-server@3.1.14
✨  Done in 2.65s.
Webpacker successfully installed πŸŽ‰ 🍰
      create  app/javascript
      create  app/javascript/packs/application.js
      create  app/javascript/packs/theme.scss
      create  app/javascript/src/jets/crud.js
      insert  config/webpack/environment.js
         run  yarn add bootstrap@4.0.0-beta jquery popper.js from "."
yarn add v1.13.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning " > webpack-dev-server@3.1.14" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.4.0" has unmet peer dependency "webpack@^4.0.0".
[4/4] πŸ”¨  Building fresh packages...
success Saved 2 new dependencies.
info Direct dependencies
β”œβ”€ jquery@3.3.1
└─ popper.js@1.14.7
info All dependencies
β”œβ”€ jquery@3.3.1
└─ popper.js@1.14.7
✨  Done in 2.63s.
         run  git init from "."
Initialized empty Git repository in /Users/timothysabat/Development/visinote/jets_demo/demo/.git/
         run  git add . from "."
         run  git commit -m 'first commit' from "."
[master (root-commit) 2289bc2] first commit
 44 files changed, 1170 insertions(+)
 create mode 100644 .babelrc
 create mode 100644 .gitignore
 create mode 100644 .jetskeep
 create mode 100644 .postcssrc.yml
 create mode 100644 .rspec
 create mode 100644 Gemfile
 create mode 100644 Gemfile.lock
 create mode 100644 Procfile
 create mode 100644 README.md
 create mode 100644 Rakefile
 create mode 100644 app/controllers/application_controller.rb
 create mode 100644 app/helpers/application_helper.rb
 create mode 100644 app/javascript/packs/application.js
 create mode 100644 app/javascript/packs/theme.scss
 create mode 100644 app/javascript/src/jets/crud.js
 create mode 100644 app/jobs/application_job.rb
 create mode 100644 app/models/application_item.rb
 create mode 100644 app/models/application_record.rb
 create mode 100644 app/views/layouts/application.html.erb
 create mode 100755 bin/webpack
 create mode 100755 bin/webpack-dev-server
 create mode 100644 config.ru
 create mode 100644 config/application.rb
 create mode 100644 config/database.yml
 create mode 100644 config/dynamodb.yml
 create mode 100644 config/environments/development.rb
 create mode 100644 config/environments/production.rb
 create mode 100644 config/routes.rb
 create mode 100644 config/webpack/development.js
 create mode 100644 config/webpack/environment.js
 create mode 100644 config/webpack/production.js
 create mode 100644 config/webpack/staging.js
 create mode 100644 config/webpack/test.js
 create mode 100644 config/webpacker.yml
 create mode 100644 db/.gitkeep
 create mode 100644 public/404.html
 create mode 100644 public/422.html
 create mode 100644 public/500.html
 create mode 100644 public/favicon.ico
 create mode 100644 public/index.html
 create mode 100644 spec/controllers/posts_controller_spec.rb
 create mode 100644 spec/fixtures/payloads/posts-index.json
 create mode 100644 spec/fixtures/payloads/posts-show.json
 create mode 100644 spec/spec_helper.rb
================================================================
Congrats πŸŽ‰ You have successfully created a Jets project.

Cd into the project directory:
  cd demo

So, when you run the server, you get an error looking for node_modules/.bin/webapcker

[Webpacker] Compiling…
[Webpacker] Compilation failed:

bundler: failed to load command: webpack (/Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bin/webpack)
Errno::ENOENT: No such file or directory - /Users/timothysabat/Development/visinote/jets_demo/demo/node_modules/.bin/webpack
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/webpacker-3651cc317358/lib/webpacker/webpack_runner.rb:11:in `exec'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/webpacker-3651cc317358/lib/webpacker/webpack_runner.rb:11:in `block in run'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/webpacker-3651cc317358/lib/webpacker/webpack_runner.rb:10:in `chdir'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/webpacker-3651cc317358/lib/webpacker/webpack_runner.rb:10:in `run'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/webpacker-3651cc317358/lib/webpacker/runner.rb:6:in `run'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bundler/gems/webpacker-3651cc317358/exe/webpack:8:in `<top (required)>'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bin/webpack:23:in `load'
  /Users/timothysabat/.rbenv/versions/2.5.3/lib/ruby/gems/2.5.0/bin/webpack:23:in `<top (required)>'

ActionView::Template::Error: Webpacker can't find application.js in /Users/timothysabat/Development/visinote/jets_demo/demo/public/packs/manifest.json. Possible causes:
1. You want to set webpacker.yml value of compile to true for your environment
   unless you are using the `webpack -w` or the webpack-dev-server.
2. webpack has not yet re-run to reflect updates.
3. You have misconfigured Webpacker's config/webpacker.yml file.
4. Your webpack configuration is not creating a manifest.
Your manifest contains:

Step-by-step reproduction instructions

Solution Suggestion

Maybe a new version has stopped creating this file?

tongueroo commented 5 years ago

@tsabat Thanks for the details.

RE: Maybe a new version has stopped creating this file?

Don't believe new versions have stopped creating the package.json. As part of jets new a jets webpacker:install command gets ran. Here's the area of the code:

https://github.com/tongueroo/jets/blob/c56ad75b4dc2aa9a9af5a5a83d75ad1e82f3dd28/lib/jets/commands/new.rb#L68-L88

Unsure here. Wondering if it might be a yarn or node setup or version thing? Just tested it and it created the package.json πŸ€”

$ jets --version
1.6.9
$ jets new demo --database=postgresql
Creating new project called demo.
      create  demo
...
$ ls demo/package.json 
demo/package.json
$ node --version
v8.10.0
$ yarn --version
1.9.4
$ 

Full gist: https://gist.github.com/tongueroo/1a3b27edfaa5033ed2332767f2b5c08a

tsabat commented 5 years ago

Here's mine

visinote/jets_demo/demo on ξ‚  master [!?] 
[I] ➜ jets --version
1.6.9

visinote/jets_demo/demo on ξ‚  master [!?] took 3s 
[I] ➜ node --version
v8.15.0

visinote/jets_demo/demo on ξ‚  master [!?] 
[I] ➜ yarn --version
1.13.0

as you can see in the original ticket, the yarn install happens, but the node_modules directory is not created at the root of my project and the package.json is missing:

[I] ➜ ls -lh 
total 28K
-rw-r--r-- 1 timothysabat staff  684 Feb  8 09:16 Gemfile
-rw-r--r-- 1 timothysabat staff 4.7K Feb  8 09:16 Gemfile.lock
-rw-r--r-- 1 timothysabat staff  282 Feb  8 09:16 Procfile
-rw-r--r-- 1 timothysabat staff  256 Feb  8 09:16 README.md
-rw-r--r-- 1 timothysabat staff   31 Feb  8 09:16 Rakefile
drwxr-xr-x 8 timothysabat staff  256 Feb  8 09:16 app
drwxr-xr-x 4 timothysabat staff  128 Feb  8 09:16 bin
drwxr-xr-x 9 timothysabat staff  288 Feb  8 09:16 config
-rw-r--r-- 1 timothysabat staff  115 Feb  8 09:16 config.ru
drwxr-xr-x 4 timothysabat staff  128 Feb  8 09:26 db
drwxr-xr-x 7 timothysabat staff  224 Feb  8 09:16 public
drwxr-xr-x 5 timothysabat staff  160 Feb  8 09:16 spec
drwxr-xr-x 3 timothysabat staff   96 Feb  8 09:26 tmp

Any suggestions for debugging? I'm not scared of the command line, but I'm unfamiliar with the node ecosystem.

tsabat commented 5 years ago

here's me installing webpack individually.


   identical  config/webpacker.yml
Copying webpack core config
       exist  config/webpack
   identical  config/webpack/development.js
    conflict  config/webpack/environment.js
Overwrite /Users/timothysabat/Development/visinote/jets_demo/demo/config/webpack/environment.js? (enter "h" for help) [Ynaqdhm] 
       force  config/webpack/environment.js
   identical  config/webpack/production.js
   identical  config/webpack/staging.js
   identical  config/webpack/test.js
Copying .postcssrc.yml to app root directory
   identical  .postcssrc.yml
Copying .babelrc to app root directory
   identical  .babelrc
Installing binstubs
         run  bundle binstubs webpacker from "."
Skipped webpack and webpack-dev-server since they already exist.
If you want to overwrite skipped stubs, use --force.
      append  .gitignore
Installing all JavaScript dependencies
         run  yarn add @rails/webpacker coffeescript@1.12.7 from "."
yarn add v1.13.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
warning " > webpack-dev-server@3.1.14" has unmet peer dependency "webpack@^4.0.0".
warning "webpack-dev-server > webpack-dev-middleware@3.4.0" has unmet peer dependency "webpack@^4.0.0".
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
[4/4] πŸ”¨  Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ @rails/webpacker@3.5.5
info All dependencies
└─ @rails/webpacker@3.5.5
✨  Done in 2.98s.
Installing dev server for live reloading
         run  yarn add --dev webpack-dev-server from "."
yarn add v1.13.0
warning package-lock.json found. Your project contains lock files generated by tools other than Yarn. It is advised not to mix package managers in order to avoid resolution inconsistencies caused by unsynchronized lock files. To clear this warning, remove package-lock.json.
[1/4] πŸ”  Resolving packages...
[2/4] 🚚  Fetching packages...
[3/4] πŸ”—  Linking dependencies...
warning "@rails/webpacker > postcss-cssnext@3.1.0" has unmet peer dependency "caniuse-lite@^1.0.30000697".
warning "webpack-dev-server > webpack-dev-middleware@3.4.0" has unmet peer dependency "webpack@^4.0.0".
warning " > webpack-dev-server@3.1.14" has unmet peer dependency "webpack@^4.0.0".
[4/4] πŸ”¨  Building fresh packages...
success Saved 1 new dependency.
info Direct dependencies
└─ webpack-dev-server@3.1.14
info All dependencies
└─ webpack-dev-server@3.1.14
✨  Done in 2.58s.
Webpacker successfully installed πŸŽ‰ 🍰
       exist  app/javascript
   identical  app/javascript/packs/application.js
   identical  app/javascript/packs/theme.scss
   identical  app/javascript/src/jets/crud.js

visinote/jets_demo/demo on ξ‚  master [!?] took 19s 
[I] ➜ ls
Gemfile  Gemfile.lock  Procfile  README.md  Rakefile  app  bin  config  config.ru  db  public  spec  tmp```
tsabat commented 5 years ago

yeah, it was some sort of node env setting, but it's unknown what the issue was. I created a new dir in my home (~) dir and installed and everything worked fine.

nic-lan commented 5 years ago

Hi @tsabat, I am experiencing the same issue.

I would be very thankful if you could clarify the following: "I created a new dir in my home (~) dir and installed and everything worked fine."

1) What dir did you create in your home ? 2) what did you installed in there ?

Thank you