© 2019 CERN. for the LHCb Collaboration. The first measurement of heavy-flavor production by the LHCb experiment in its fixed-target mode is presented. The production of J/ψ and D0 mesons is studied with beams of protons of different energies colliding with gaseous targets of helium and argon with nucleon-nucleon center-of-mass energies of sNN=86.6 and 110.4 GeV, respectively. The J/ψ and D0 production cross sections in pHe collisions in the rapidity range [2, 4.6] are found to be σJ/ψ=652±33(stat)±42(syst) nb/nucleon and σD0=80.8±2.4(stat)±6.3(syst) μb/nucleon, where the first uncertainty is statistical and the second is systematic. No evidence for a substantial intrinsic charm content of the nucleon is observed in the large Bjorken-x region.