How to add javascripts in middleman 4?

In the previous version of Middleman was used to add the following javascripts.

// = require “jquery”

What is the correct version for version 4?

The //= require syntax is from Sprockets. Middleman 4 has removed the use of Sprockets from the core. You can use External Pipeline to use JS build tools, such as Webpack, to manage JS assets. Or, if you prefer the old Sprockets way, you just need to enable it in config.rb.

To do so, add this dependency in Gemfile:

gem 'middleman-sprockets', '~> 4.1.0'

Then, in config.rb:

activate :sprockets

And, you will be able to use Sprockets directives again. Hope this helps.