【问题标题】:substrate-developer-hub/substrate-front-end-template run yarn error基板开发者集线器/基板前端模板运行纱线错误
【发布时间】:2022-01-18 01:24:48
【问题描述】:

运行纱线构建

yarn run v1.22.17
$ react-scripts build
Creating an optimized production build...
Failed to compile.

./node_modules/@polkadot/api/node_modules/@polkadot/keyring/packageInfo.js 6:27
Module parse failed: Unexpected token (6:27)
File was processed with these loaders:
 * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| export var packageInfo = {
|   name: '@polkadot/keyring',
>   path: new URL('.', import.meta.url).pathname,
|   type: 'esm',
|   version: '8.3.2'


error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.

package.json

"dependencies": {
    "@polkadot/api": "^6.7.2",
    "@polkadot/extension-dapp": "^0.41.1",
    "@polkadot/keyring": "^7.8.2",
    "@polkadot/networks": "^7.8.2",
    "@polkadot/types": "^6.7.2",
    "@polkadot/ui-keyring": "^0.86.5",
    "@polkadot/ui-settings": "^0.86.5",
    "@polkadot/util": "^7.8.2",
    "@polkadot/util-crypto": "^7.8.2",
    "@testing-library/jest-dom": "^5.16.1",
    "@testing-library/react": "^12.1.2",
    "@testing-library/user-event": "^13.5.0",
    "prop-types": "^15.7.2",
    "query-string": "^7.0.1",
    "react": "^17.0.2",
    "react-copy-to-clipboard": "^5.0.4",
    "react-dom": "^17.0.2",
    "react-scripts": "^4.0.3",
    "web-vitals": "^2.1.3"
  },
  "scripts": {
    "start": "react-scripts start",
    "build": "react-scripts build",
    "test": "react-scripts test",
    "eject": "react-scripts eject"
  },

$ react-scripts build 创建优化的生产构建... 编译失败。 命令失败,退出代码为 1。 info 访问https://yarnpkg.com/en/docs/cli/run 获取有关此命令的文档。

【问题讨论】:

    标签: substrate polkadot


    【解决方案1】:

    根据我的经验,我遇到了同样的问题,并意识到这是因为依赖版本已经更新到 yarn.lock 文件依赖版本之外。因此,当我删除 yarn.lock 文件并执行 yarn install 时,使用新的依赖版本创建了一个新的 yarn.lock 文件并给了我同样的错误:

    Creating an optimized production build...
    Failed to compile.
    
    ./node_modules/@polkadot/api/node_modules/@polkadot/keyring/packageInfo.js 6:27
    Module parse failed: Unexpected token (6:27)
    File was processed with these loaders:
     * ./node_modules/react-scripts/node_modules/babel-loader/lib/index.js
    You may need an additional loader to handle the result of these loaders.
    | export var packageInfo = {
    |   name: '@polkadot/keyring',
    >   path: new URL('.', import.meta.url).pathname,
    |   type: 'esm',
    |   version: '8.3.2'
    

    确保从 Github 重新克隆模板项目,不要删除 yarn.lock 文件以保留旧版本。最终,您必须设法更新版本以使其正常工作,但如果您只想使用基板和响应前端,则暂时是这样。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 2022-02-26
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-03-01
      相关资源
      最近更新 更多