Heroku没有找到私人NPM包

问题描述 投票:0回答:1

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

我使用私有模块为我的反应应用程序,使用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个回答
1
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.