Get version number from package.json in React Redux (create-react-app)

后端 未结 4 1220
悲哀的现实
悲哀的现实 2021-02-01 11:34

OP EDIT: If anyone else comes across this: the app was created using create-react-app, which limits importing to within the src folder. However if you upgrade react-scri

4条回答
  •  孤街浪徒
    2021-02-01 12:21

    Try this.

    // in package.json
    "version": "1.0.0"
    
    // in index.js
    import packageJson from '../package.json';
    console.log(packageJson.version); // "1.0.0"
    

提交回复
热议问题