我已经尝试了书中所有内容,但仍然遇到相同的错误。 令人惊讶的是,我在其他任何地方都没有找到这个确切的错误。
remote: error Couldn't find a package.json file in "/tmp/build_0e5b0c14c98db4a63ddfc87fc6d11490"
Here is the full error on Pastebin
Here is the repository for the (rather simple) blogger project
我什至尝试在本地运行rake assets:precompile
,并且完全没有错误。
我运行了RAILS_ENV=production bundle exec rake assets:precompile
,被推送到我的仓库中,然后尝试部署,什么也没有。
我通过成堆的StackOverflow问题大吃一惊,并尝试使用谷歌搜索我的错误,给我遇到的每个编辑/命令都尝试了一次,但是没有运气。
编辑:以下是我的package.json文件的内容
{
"name": "blogger",
"private": true,
"dependencies": {
"@rails/actioncable": "^6.0.0",
"@rails/activestorage": "^6.0.0",
"@rails/ujs": "^6.0.0",
"@rails/webpacker": "4.2.2",
"turbolinks": "^5.2.0"
},
"version": "0.1.0",
"devDependencies": {
"webpack-dev-server": "^3.10.1"
}
}
答案 0 :(得分:1)
Rails 6的基本配置:-
运行yarn install
,或仅运行yarn
。它将创建一个package.json文件:-
package.json'
此文件包含您的Webpack所需的软件包。
有关更多参考,请阅读:-
如果要在生产环境中进行预编译,请在以下文件中更改配置:-
config/webpacker.yml
production:
<<: *default
# Production depends on precompilation of packs prior to booting for performance.
compile:true ## just make this compile true
# Extract and emit a css file
extract_css: true
# Cache manifest.json for performance
cache_manifest: true
然后执行命令:-
RAILS_ENV=production rake assets:clobber
RAILS_ENV=production rake assets:precompile
答案 1 :(得分:0)
我的package.json文件在我的Github存储库中不存在,尽管它确实存在在我的本地系统中。
我没有任何待提交的待提交文件,我的.gitignore没有显示任何json文件的排除。 我不确定为什么没有将其上传到我的存储库。
所以我不得不通过运行以下命令来强制将其添加到登台区域:
string path = @"C:\Data\Countries.xml";
if (!File.Exists(path))
{
File.Create(path).Dispose();
using (TextWriter tw = new StreamWriter(path))
{
tw.WriteLine("The very first line!");
tw.Close();
}
}
else if (File.Exists(path))
{
using (TextWriter tw = new StreamWriter(path))
{
tw.WriteLine("The next line!");
tw.Close();
}
}
//for (int i = 0; i < count; ++i)
//{
// System.IO.File.Delete(@"C:\Data\C#\Example.txt");
//}
}
[Serializable()]
public class Country
{
[System.Xml.Serialization.XmlElement("Population")]
public string Population { get; set; }
[System.Xml.Serialization.XmlElement("Name")]
public string Name { get; set; }
}
[Serializable()]
[System.Xml.Serialization.XmlRoot("CountriesCollection")]
public class CountriesCollection
{
[XmlArray("Countries")]
[XmlArrayItem("Country", typeof(Country))]
public Country[] Country { get; set; }
}
private void btnDelete_Click(object sender, EventArgs e)
{
//DataSet ds = new DataSet();
//ds.ReadXml(@"C:\Users\Curso\Desktop\xmls\qq.xml");
// dataGridView1.DataSource = ds.Tables[0];
/* public static T DeserializeFromXml<Empleado>(@"C:\Users\Curso\Desktop\xmls\qq.xml");
{
T result;
XmlSerializer ser = new XmlSerializer(typeof(T));
using (TextReader tr = new StringReader(xml))
{
result = (T)ser.Deserialize(tr);
}
return result;
}*/
/*
XmlSerializer ser = new XmlSerializer(typeof(Car));
Car myObject;
using (XmlReader reader = XmlReader.Create(@"C:\Data\A\cars.xml"))
{
myObject = (Car)ser.Deserialize(reader);
}*/
CountriesCollection countries = null;
string path = @"C:\Data\A\cars.xml";
XmlSerializer serializer = new XmlSerializer(typeof(CountriesCollection));
StreamReader reader = new StreamReader(path);
countries = (CountriesCollection)serializer.Deserialize(reader);
reader.Close();
foreach (Country country in countries.Country)
{
Debug.WriteLine("País: " + country.Name + " Población: " + country.Population);
}
/*foreach(Country country in countries)
{
Debug.WriteLine("Countries:: " + country);
}*/
Console.WriteLine("{" + string.Join(", ", countries.Country.ToString()) + "}");
(记入@San's answer to a different question)。
然后,我简单地进行了更改并成功推送到Heroku!