When Trying run yarn, throw err; (Ubuntu) - environment

When installing a development environment on my computer with yarn, I get the following error. I have already deleted NVM and YARN and reinstalled them but still, I get the same error:
yarn stg
internal/modules/cjs/loader.js:905
throw err;
^
Error: Cannot find module '/mnt/c/Users/David/.yarn/releases/yarn-3.2.0.cjs'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:902:15)
at Function.Module._load (internal/modules/cjs/loader.js:746:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:75:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
}

Related

Rails 6.1.0 [webpack-cli] TypeError: Cannot read property 'plugins' of undefined

My Rails+Webpack app contanizered with Docker worked fine in 6.0.3.4 and with
"webpack": "^4.44.1",
"webpack-cli": "^3.3.9"
After upgrade to 6.1.0 webpack-cli cannot read property 'plugins' (or 'config' or 'loaders') in the environment.js during assets:precompile.
...Step 20/22 : RUN bundle exec rake RAILS_ENV=staging assets:precompile
---> Running in bca898bb9014
yarn install v1.22.5
warning package.json: No license field
warning No license field
[1/4] Resolving packages...
[2/4] Fetching packages...
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...
warning " > tempusdominus-bootstrap-4#5.39.0" has unmet peer dependency "moment#^2.29.0".
warning " > tempusdominus-bootstrap-4#5.39.0" has unmet peer dependency "moment-timezone#^0.5.31".
warning " > tempusdominus-bootstrap-4#5.39.0" has unmet peer dependency "tempusdominus-core#5.19.0".
warning "webpack-dev-server > webpack-dev-middleware#3.7.2" has incorrect peer dependency "webpack#^4.0.0".
[4/4] Building fresh packages...
Done in 4.28s.
I, [2021-01-10T14:31:28.268903 #7] INFO -- : Writing /var/www/<RoR-app>/public/assets/manifest-a72913f4c604bc8f97dd576fc8777bf029401f6af0e14b6a6c9d3874acfe73e4.js
I, [2021-01-10T14:31:28.269857 #7] INFO -- : Writing /var/www/<RoR-app>/public/assets/manifest-a72913f4c604bc8f97dd576fc8777bf029401f6af0e14b6a6c9d3874acfe73e4.js.gz
Compiling...
Compilation failed:
warning package.json: No license field
[webpack-cli] Failed to load '/var/www/<RoR-app>/config/webpack/production.js'
[webpack-cli] TypeError: Cannot read property 'plugins' of undefined
at Object.<anonymous> (/var/www/<RoR-app>/config/webpack/environment.js:7:13)
at Module._compile (/var/www/<RoR-app>/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
at Module.load (internal/modules/cjs/loader.js:928:32)
at Function.Module._load (internal/modules/cjs/loader.js:769:14)
at Module.require (internal/modules/cjs/loader.js:952:19)
at require (/var/www/<RoR-app>/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
at Object.<anonymous> (/var/www/<RoR-app>/config/webpack/production.js:3:21)
at Module._compile (/var/www/<RoR-app>/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
at Object.Module._extensions..js (internal/modules/cjs/loader.js:1092:10)
ERROR: Service 'ruby' failed to build: The command '/bin/sh -c bundle exec rake RAILS_ENV=staging assets:precompile' returned a non-zero code: 1
config/webpack/production.js
process.env.NODE_ENV = process.env.NODE_ENV || 'production'
const environment = require('./environment')
module.exports = environment.toWebpackConfig()
config/webpack/environment.js
const { environment } = require('#rails/webpacker');
const webpack = require('webpack');
const expose = require('./loaders/expose');
const coffee = require('./loaders/coffee');
const erb = require('./loaders/erb');
environment.plugins.prepend('Provide',
new webpack.ProvidePlugin({
$: 'jquery',
jQuery: 'jquery',
jquery: 'jquery',
Popper: ['popper.js', 'default'],
Rails: ['#rails/ujs'],
moment: 'moment'
})
);
...
package.json
{
"dependencies": {
"#rails/ujs": "^6.1.1",
"#rails/webpacker": "^6.0.0-pre.1",
"bloodhound-js": "^1.2.3",
"bootstrap": "^4.5.3",
"clean-webpack-plugin": "^3.0.0",
"cocoon": "github:nathanvda/cocoon#c24ba53",
"core-js": "^3.8.2",
"css-loader": "^5.0.1",
"exports-loader": "^1.1.1",
"expose-loader": "^1.0.3",
"file-loader": "^6.2.0",
"font-awesome": "^4.7.0",
"jbuilder": "^0.0.5",
"jquery": "^3.5.1",
"jquery-ui": "^1.12.1",
"jquery-ui-dist": "^1.12.1",
"jquery-ujs": "^1.2.2",
"jstree": "^3.3.11",
"popper.js": "^1.16.1",
"sidekiq": "^1.1.1",
"tempusdominus-bootstrap-4": "^5.39.0",
"turbolinks": "^5.2.0",
"webpack": "^5.12.2",
"webpack-cli": "^4.3.1",
"webpack-dev-middleware": "^4.0.2",
"webpack-dev-server": "^3.11.1"
},
"devDependencies": {}
}
toWebpackConfig does not exist in 6.x. (https://github.com/rails/webpacker/issues/2875)
webpacker gem v.6.0 isn't released yet (https://rubygems.org/gems/webpacker)

Bundler error when deploying Rails 6 App to Elastic Beanstalk

I've been struggling getting around the well known bundler 2.0.x error when deploying to both Heroku and AWS Elastic Beanstalk. After trying many of the suggested remedies like updating gems and installing bundler 2.0.x or bundler update --system. None of this has worked so far. I found a solution to create a file in .ebextensions like so:
files:
# Runs before \./10_bundle_install.sh`:`
"/opt/elasticbeanstalk/hooks/appdeploy/pre/09_gem_install_bundler.sh" :
mode: "000775"
owner: root
group: users
content: |
#!/usr/bin/env bash
EB_APP_STAGING_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k app_staging_dir)
EB_SCRIPT_DIR=$(/opt/elasticbeanstalk/bin/get-config container -k script_dir)
# Source the application's ruby, i.e. 2.6. Otherwise it will be 2.3, which will give this error: \bundler requires Ruby version >= 2.3.0``
. $EB_SCRIPT_DIR/use-app-ruby.sh
cd $EB_APP_STAGING_DIR
echo "Installing compatible bundler"
gem install bundler -v 2.1.0.pre.2
This is the error I'm still getting on eb deploy staging-1:
Creating application version archive "app-7b50-191111_122622".
Uploading: [##################################################] 100% Done...
2019-11-11 17:28:21 INFO Environment update is starting.
2019-11-11 17:28:28 INFO Deploying new version to instance(s).
2019-11-11 17:31:36 ERROR [Instance: i-0ba40e32901557bee] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ystem, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.0.pre.2`
from /opt/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
from /opt/rubies/ruby-2.6.5/bin/bundle:23:in `<main>'.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-11-11 17:31:36 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2019-11-11 17:31:36 ERROR Unsuccessful command execution on instance id(s) 'i-0ba40e32901557bee'. Aborting the operation.
2019-11-11 17:31:37 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.
[12:31:40] (master) tml_portal
// ♥ eb deploy staging-1
Creating application version archive "app-7b50-191111_123229".
Uploading: [##################################################] 100% Done...
2019-11-11 17:34:45 INFO Environment update is starting.
2019-11-11 17:34:53 INFO Deploying new version to instance(s).
2019-11-11 17:37:47 ERROR [Instance: i-0ba40e32901557bee] Command failed on instance. Return code: 1 Output: (TRUNCATED)...ystem, run `bundle update --bundler`.
To install the missing version, run `gem install bundler:2.1.0.pre.2`
from /opt/rubies/ruby-2.6.5/lib/ruby/site_ruby/2.6.0/rubygems.rb:303:in `activate_bin_path'
from /opt/rubies/ruby-2.6.5/bin/bundle:23:in `<main>'.
Hook /opt/elasticbeanstalk/hooks/appdeploy/pre/10_bundle_install.sh failed. For more detail, check /var/log/eb-activity.log using console or EB CLI.
2019-11-11 17:37:47 INFO Command execution completed on all instances. Summary: [Successful: 0, Failed: 1].
2019-11-11 17:37:47 ERROR Unsuccessful command execution on instance id(s) 'i-0ba40e32901557bee'. Aborting the operation.
2019-11-11 17:37:48 ERROR Failed to deploy application.
ERROR: ServiceError - Failed to deploy application.
Any ideas on how to get around this dreaded Bundler issue for deployment?
It still the missing bundle version error. Could you try following:
#.ebextensions/bundler_update.config
commands:
update_bundler:
command: /opt/rubies/ruby-2.6.5/bin/gem install bundler -v 2.1.0.pre.2
Ruby and Bundler version should match yours.

Webpacker Node Module Bin Error No such file or directory

I am runnning a rails 5.1.5 app with webpacker 3.5.5. My assets precompile locally without an error. When I deploy to digitalocean server, I get the following error and do not know why.
Here is the output from the capistrano deployment logs:
DEBUG [206c5aa1] Command: cd /var/www/dolgins_production/releases/20190213201703 && ( export RAILS_ENV="production" ; bundle exec rake assets:precompile )
DEBUG [8c98d080] yarn install v1.13.0
DEBUG [8c98d080] [1/4] Resolving packages...
DEBUG [8c98d080] success Already up-to-date.
DEBUG [8c98d080] Done in 1.65s.
DEBUG [8c98d080] Webpacker is installed 🎉 🍰
DEBUG [8c98d080]
DEBUG [8c98d080] Using /var/www/dolgins_production/releases/20190213201703/config/webpacker.yml file for setting up webpack paths
DEBUG [8c98d080]
DEBUG [8c98d080] Compiling…
DEBUG [8c98d080] Compilation failed:
/var/www/dolgins_production/shared/bundle/ruby/2.4.0/gems/webpacker-3.5.5/lib/webpacker/webpack_runner.rb:11:in `exec': No such file or directory - /var/www/dolgins_production/releases/20190213201703/node_modules/.bin/webpack (Errno::ENOENT)
from /var/www/dolgins_production/shared/bundle/ruby/2.4.0/gems/webpacker-3.5.5/lib/webpacker/webpack_runner.rb:11:in `block in run'
from /var/www/dolgins_production/shared/bundle/ruby/2.4.0/gems/webpacker-3.5.5/lib/webpacker/webpack_runner.rb:10:in `chdir'
from /var/www/dolgins_production/shared/bundle/ruby/2.4.0/gems/webpacker-3.5.5/lib/webpacker/webpack_runner.rb:10:in `run'
from /var/www/dolgins_production/shared/bundle/ruby/2.4.0/gems/webpacker-3.5.5/lib/webpacker/runner.rb:6:in `run'
from ./bin/webpack:15:in `<main>'
I am deploying to Ubuntu 14. Not sure what to try. I have looked for solutions but found nothing that has worked.
Thank you.

Rails - Vuejs run with Foreman

I'm try to start my first application with ruby on rails and vuejs.
I use https://mkdev.me/en/posts/rails-5-vue-js-how-to-stop-worrying-and-love-the-frontend to learn and create my application as a tutorial.
Everything is good but when i try to run $ foreman start my cmd throws some error:
21:48:11 frontend.1 | internal/modules/cjs/loader.js:596
21:48:11 frontend.1 | throw err;
21:48:11 frontend.1 | ^
21:48:11 frontend.1 |
21:48:11 frontend.1 | Error: Cannot find module 'ajv'
21:48:11 frontend.1 | at Function.Module._resolveFilename (internal/modules/cjs/loader.js:594:15)
21:48:11 frontend.1 | at Function.Module._load (internal/modules/cjs/loader.js:520:25)
21:48:11 frontend.1 | at Module.require (internal/modules/cjs/loader.js:650:17)
21:48:11 frontend.1 | at require (internal/modules/cjs/helpers.js:20:18)
21:48:11 frontend.1 | at Object.<anonymous> (C:\Users\Hieu Vo\AppData\Roaming\npm\node_modules\webpack\node_modules\schema-utils\src\validateOptions.js:11:13)
21:48:11 frontend.1 | at Module._compile (internal/modules/cjs/loader.js:702:30)
21:48:11 frontend.1 | at Object.Module._extensions..js (internal/modules/cjs/loader.js:713:10)
21:48:11 frontend.1 | at Module.load (internal/modules/cjs/loader.js:612:32)
21:48:11 frontend.1 | at tryModuleLoad (internal/modules/cjs/loader.js:551:12)
21:48:11 frontend.1 | at Function.Module._load (internal/modules/cjs/loader.js:543:3)
Here is my Procfile:
rails: rails s -p 3000
frontend: webpack-dev-server
I hope you can help me resolve this issue. Thank you very much.
Try
npm install ajv
Then run again

deploying ruby on rails app using capistrano - cap deploy:setup failing

I've wasted a few days on this problem and I'm sure it's a simple solution, please help!
When I run $ cap deploy:setup from my user account on my laptop I get the errors I've pasted below. It seems that there's a problem with RVM, but I know that it's installed, and I've pre-installed all the gems my app will need as well. Has anyone else encountered similar errors? Any help would be hugely appreciated!
* executing `deploy:setup'
* executing "mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids"
servers: ["arbiter.nullpointer.ca"]
[arbiter.nullpointer.ca] executing command
** [out :: arbiter.nullpointer.ca]
** [out :: arbiter.nullpointer.ca] $rvm_path (system_wide) does not exist.
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/scripts/rvm: line 154: __rvm_teardown: command not found
*** [err :: arbiter.nullpointer.ca] /usr/local/rvm/bin/rvm-shell: line 74: rvm: command not found
*** [err :: arbiter.nullpointer.ca] Error: RVM was unable to use 'default'
command finished
failed: "rvm_path=system_wide /usr/local/rvm/bin/rvm-shell 'default' -c \"mkdir -p /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids && chmod g+w /usr/local/www/sites/arbiter.nullpointer.ca/public/ /usr/local/www/sites/arbiter.nullpointer.ca/public/releases /usr/local/www/sites/arbiter.nullpointer.ca/public/shared /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/system /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/log /usr/local/www/sites/arbiter.nullpointer.ca/public/shared/pids\"" on arbiter.nullpointer.ca
I just ran into this problem though my installation was complaining with:
out :: server]
** [out :: server] $rvm_path (/home/nebula/.rvm/) does not exist.
*** [err :: server] /usr/local/rvm/scripts/rvm: line 185: __rvm_teardown: command not found
*** [err :: server] /usr/local/rvm/bin/rvm: line 52: /home/nebula/.rvm//scripts/rvm: No such file or directory
*** [err :: server] Error sourcing RVM!
*** [err :: server] Error: RVM was unable to use 'ruby-1.9.3-p392'
I am using rvm with a system wide install, (standard install to /usr/local/rvm). Adding the following to my Capfile solved the issue:
set :rvm_type, :system
set :rvm_path, "/usr/local/rvm"
The Error shows: RVM was unable to use 'default' gemset. Means RVM can't find a gemset named 'default' to use. Check the following line in your deploy.rb
set :rvm_ruby_string, 'gemset-name-here' => put a valid gemset here

Resources