Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/ruby-on-rails/59.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Node.js 运行Rails服务器-Webpacker安装_Node.js_Ruby On Rails_Ruby_Yarnpkg - Fatal编程技术网

Node.js 运行Rails服务器-Webpacker安装

Node.js 运行Rails服务器-Webpacker安装,node.js,ruby-on-rails,ruby,yarnpkg,Node.js,Ruby On Rails,Ruby,Yarnpkg,我遵循了RubyonRails的安装说明,详细介绍如下:,但是我在运行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

我遵循了RubyonRails的安装说明,详细介绍如下:,但是我在运行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安装会让我:

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
I solved this problem like this:

  • Using Homebrew
    $ brew install node
Michaels MBP:myapp mh$brew安装程序
正在更新自制。。。
==>下载https://homebrew.bintray.com/bottles/node-14.4.0.mojave.bottle.tar.gz
==>从下载https://akamai.bintray.com/06/06ef204701e93bbcf3909dba4ac9d3ca1d4df
######################################################################## 100.0%
==>下载https://yarnpkg.com/downloads/1.22.4/yarn-v1.22.4.tar.gz
==>从下载https://github-production-release-asset-2e65be.s3.amazonaws.com/499
######################################################################## 100.0%
==>安装纱线:节点的依赖项
==>安装纱线相关性:节点
==>浇注节点-14.4.0.mojave.bottle.tar.gz
错误:“brew链接”步骤未成功完成
公式已生成,但未符号链接到/usr/local
无法对bin/节点进行符号链接
目标/usr/local/bin/node
已经存在。您可能要删除它:
rm'/usr/local/bin/node'
警告:安装后步骤未成功完成
您可以使用“brew后安装节点”重试`
==>注意事项
Bash completion已安装到:
/usr/local/etc/bash_completion.d
==>摘要

我是这样解决这个问题的:

  • 使用自制软件
  • 然后安装webpacker
  • 确保所有包都是最新的
  • 而且。。。祝你好运,启动你的Rails服务器

您没有写入的权限。尝试使用:$sudo chown-R$USER:admin/usr/local/include/node,或者尝试授予写入include文件夹的权限。然后再试一次。是的。。。我就是这么想的:)!来吧,你差点就成功了!他可以在本地主机上看到这个页面:3000作为记录,它需要大约4个小时才能工作。谢谢托尼,从这里开始一切都是下坡路,对吧…?太好了!我希望如此:')
    $ rails webpacker:install
    $ yarn install --check-files
    $ rails s