【问题标题】:Running Rails Server - Webpacker installation运行 Rails 服务器 - Webpacker 安装
【发布时间】:2020-10-20 22:15:01
【问题描述】:

我已按照 https://gorails.com/setup/osx/10.14-mojave 上详述的 Setup Ruby on Rails 说明进行操作,但在运行 Rails 服务器时遇到问题...

ruby 2.7.1p83 (2020-03-31 revision a0c7c23c9c) [x86_64-darwin18]
Michaels-MBP:myapp mh$ rbenv versions
  system
* 2.7.1 (set by /Users/mh/myapp/.ruby-version)
Michaels-MBP:myapp mh$ rails -v
Rails 6.0.3.2

运行时:

rails server

我最终得到:

/Users/mh/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/webpacker-4.2.2/lib/webpacker/configuration.rb:95:in `rescue in load': Webpacker configuration file not found /Users/mh/myapp/config/webpacker.yml. Please run rails webpacker:install Error: No such file or directory @ rb_sysopen - /Users/mh/myapp/config/webpacker.yml (RuntimeError)

运行 rails webpacker install 给了我:

sh: node: command not found
sh: nodejs: command not found
Node.js not installed. Please download and install Node.js https://nodejs.org/en/download/

我已经使用网站 installer.pkg 安装了 Node.js,并获得以下信息:

Michaels-MBP:myapp mh$ brew install yarn
Updating Homebrew...
==> Downloading https://homebrew.bintray.com/bottles/node-14.4.0.mojave.bottle.tar.gz
==> Downloading from https://akamai.bintray.com/06/06ef204701e93bbcf3909dba4ac9d3ca1d4df
######################################################################## 100.0%
==> Downloading https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz
==> Downloading from https://github-production-release-asset-2e65be.s3.amazonaws.com/499
######################################################################## 100.0%
==> Installing dependencies for yarn: node
==> Installing yarn dependency: node
==> Pouring node-14.4.0.mojave.bottle.tar.gz
Error: The `brew link` step did not complete successfully
The formula built, but is not symlinked into /usr/local
Could not symlink bin/node
Target /usr/local/bin/node
already exists. You may want to remove it:
  rm '/usr/local/bin/node'

Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`
==> Caveats
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
==> Summary
????  /usr/local/Cellar/node/14.4.0: 4,659 files, 60.8MB
==> Installing yarn
????  /usr/local/Cellar/yarn/1.22.4: 14 files, 5MB, built in 2 seconds
==> Caveats
==> node
Bash completion has been installed to:
  /usr/local/etc/bash_completion.d
Michaels-MBP:myapp mh$ brew link --overwrite node
Linking /usr/local/Cellar/node/14.4.0... 
Error: Could not symlink include/node/common.gypi
/usr/local/include/node is not writable.
Michaels-MBP:myapp mh$ brew postinstall node
==> Postinstalling node
Warning: The post-install step did not complete successfully
You can try again using `brew postinstall node`

它在 Yarn 安装中说明了垫片在 PATH 中的 rbenv 垫片“之前”吗?我不确定这意味着什么......

这是我的 PATH 的副本 - 我知道它可能搞砸了...


export PATH="/usr/local/opt/ruby/bin:$PATH"

alias laptop='bash <(curl -s https://raw.githubusercontent.com/monfresh/laptop/master/laptop)'



eval "$(hub alias -s)"

if which rbenv > /dev/null; then eval "$(rbenv init -)"; fi

export PATH="$HOME/.bin:$PATH"

【问题讨论】:

    标签: node.js ruby-on-rails ruby yarnpkg


    【解决方案1】:

    我这样解决了这个问题:

    • 使用自制软件
        $ brew install node
    
    • 然后安装 webpacker
        $ rails webpacker:install
    
    • 确保所有软件包都是最新的
        $ yarn install --check-files
    
    • 还有...祝你好运,启动你的 Rails 服务器
        $ rails s
    

    【讨论】:

    • 您没有写入权限。尝试:$ sudo chown -R $USER:admin /usr/local/include/node 或者尝试授予写入包含文件夹的权限。然后再试一次。
    • 是的……我就是这么想的 :) !来吧,你几乎明白了!
    • 他可以在 LOCAL HOST:3000 上看到该页面 作为记录,这需要大约 4 个小时才能完成。谢谢托尼,从这里开始走下坡路吧……?
    • 太棒了!我希望如此:')
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2018-05-16
    • 1970-01-01
    • 1970-01-01
    • 2015-09-27
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多