0

在使用 bitbucket 管道构建我的(以前工作的)应用程序时,我遇到了以下错误:

...

[4/4] Building fresh packages...
success Saved lockfile.
success Saved 1 new dependency.
└─ babel-core@6.26.3
Done in 22.08s.
  /opt/atlassian/pipelines/agent/build/src/index.js: Cannot find module '@babel/plugin-transform-react-jsx'
    at Function.Module._resolveFilename (module.js:470:15)
    at Function.Module._load (module.js:418:25)
    at Module.require (module.js:498:17)
    at require (/opt/atlassian/pipelines/agent/build/node_modules/v8-compile-cache/v8-compile-cache.js:159:20)
    at /opt/atlassian/pipelines/agent/build/node_modules/parcel-bundler/lib/transforms/babel/jsx.js:51:22
    at Generator.next (<anonymous>)
    at asyncGeneratorStep (/opt/atlassian/pipelines/agent/build/node_modules/@babel/runtime/helpers/asyncToGenerator.js:3:24)
    at _next (/opt/atlassian/pipelines/agent/build/node_modules/@babel/runtime/helpers/asyncToGenerator.js:25:9)
npm info lifecycle parcel-react@1.0.0~build: Failed to exec build script
npm ERR! Linux 4.14.63-coreos
npm ERR! argv "/usr/local/bin/node" "/usr/local/bin/npm" "run" "build"
npm ERR! node v7.10.1
npm ERR! npm  v4.2.0
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! parcel-react@1.0.0 build: `parcel build index.html --public-url ./`
npm ERR! Exit status 1
...

package.json的脚本和依赖相关的行如下所示:

  "scripts": {
    "start": "parcel index.html",
    "build": "parcel build index.html --public-url ./",
    "deploy": "firebase deploy --token $FIREBASE_TOKEN"
  },
  ...
  "dependencies": {
    "axios": "^0.18.0",
    "babel-plugin-transform-class-properties": "^6.24.1",
    "babel-plugin-transform-object-rest-spread": "^6.26.0",
    "classnames": "^2.2.6",
    "firebase": "^5.5.7",
    "immutable": "^3.8.2",
    "lodash": "^4.17.10",
    "mark-twain": "^2.0.3",
    "node-sass": "^4.7.2",
    "parcel-plugin-markdown": "^0.3.1",
    "react": "^0.14.0 || ^15.0.0-0 || ^16.0.0-0",
    "react-dom": "^16.2.0",
    "react-iframe": "^1.3.3",
    "react-redux": "^5.0.7",
    "react-router-dom": "^4.3.1",
    "redux": "^2.0.0 || ^3.0.0 || ^4.0.0-0",
    "redux-actions": "^2.6.1",
    "redux-axios-middleware": "^4.0.0",
    "simple-markdown": "^0.4.2",
    "slate": "^0.38.1",
    "slate-plain-serializer": "^0.6.0",
    "slate-react": "^0.16.1"
  },
  "devDependencies": {
    "babel-preset-env": "^1.7.0",
    "babel-preset-react": "^6.24.1",
    "firebase-tools": "^3.19.3",
    "parcel-bundler": "^1.5.1"
  }

有谁知道是什么导致了这个错误,并且起源于哪个依赖?我试图删除所有 babel 依赖项,只是为了测试它,但仍然出现错误。

4

2 回答 2

0

在 bitbucket 中,单击管道,在右上角您可以访问缓存,在那里您可以清除 node_modules 缓存并再次重新运行,它应该构建

于 2021-01-11T12:26:48.500 回答
-1

在管道中使用 yarn 而不是 npm 解决了这个问题。无论如何,我在开发中使用了纱线。

于 2018-11-12T12:40:12.137 回答