【问题标题】:Heroku does not find private NPM packageHeroku 找不到私有 NPM 包
【发布时间】:2019-02-07 15:17:43
【问题描述】:

更新:似乎错误与我的一个私人包有关

我正在为我的 react 应用程序使用一个私有模块,使用 heroku-create-react-app 构建。

这是我在项目根文件夹中的.npmrc

//registry.npmjs.org/:_authToken={NPM_TOKEN}
init.author.name=My.Name
scope=username
@username:registry=https://registry.npmjs.org/

还有我的package.json

"dependencies": {
    "@myname/my-component": "^0.1.9",
    ...
}
"scripts": {
    "build-css": "node-sass-chokidar ./src/ -o ./src/",
    "watch-css": "npm run build-css && node-sass-chokidar src/ -o src/ --watch --recursive",
    "start-js": "react-scripts start",
    "start": "npm-run-all -p watch-css start-js",
    "build-js": "react-scripts build",
    "build": "npm-run-all build-css build-js",
    "test": "react-scripts test --env=jsdom",
    "eject": "react-scripts eject"
  }

在 heroku 上,我将环境变量设置为 NPM_TOKEN 并将令牌设置为其值。

推送到 heroku 时出现此错误:

remote: -----> Building dependencies
remote:        Installing node modules (package.json + package-lock)
remote:        npm ERR! code E404
remote:        npm ERR! 404 Not Found: @myname/my-component@https://registry.npmjs.org/@my-name/my-component/-/my-component-0.1.9.tgz
remote:

【问题讨论】:

    标签: reactjs heroku npm


    【解决方案1】:

    我没有看到名为 heroku-create-react-app 的 GitHub 存储库,但如果它是使用 create-react-app 引导的,则变量名称需要以“REACT_APP_”开头才能在变量进程下可用.env。这篇文章有更多信息:http://uidevdaily.com/2018/how-to-set-environment-specific-variables-in-a-react-app

    【讨论】:

      猜你喜欢
      • 2016-01-18
      • 1970-01-01
      • 1970-01-01
      • 2020-02-07
      • 2012-06-07
      • 1970-01-01
      • 2017-10-25
      • 1970-01-01
      • 2018-05-02
      相关资源
      最近更新 更多