在ubuntu服务器上构建next.js项目时出现webpack错误

时间:2019-08-23 08:29:39

标签: reactjs ubuntu-16.04 next.js styled-components

我有一个nextjs项目,可以在运行windows 10的本地笔记本电脑中很好地工作,但是当我从我的bitbucket存储库中克隆相同的projet并构建时,我遇到了webpack问题。

这是我的 .babelrc 配置:

{
    "presets": [
      "next/babel"
    ],
    "plugins": [
      [
        "styled-components",
        {
          "ssr": true,
          "displayName": true,
          "preprocess": false
        }
      ]
    ]
  }

package.json

{
  "name": "rdc-infrastructure-next",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "scripts": {
    "dev": "next",
    "build": "next build",
    "start": "next start"
  },
  "dependencies": {
    "@trendmicro/react-sidenav": "^0.4.5",
    "@urbica/react-map-gl": "^1.8.0",
    "@zeit/next-css": "^1.0.1",
    "@zeit/next-sass": "^1.0.1",
    "axios": "^0.19.0",
    "bootstrap": "^4.3.1",
    "chroma-js": "^2.0.4",
    "deck.gl": "^7.1.11",
    "dotenv": "^8.0.0",
    "immutable": "^4.0.0-rc.12",
    "isomorphic-unfetch": "^3.0.0",
    "lodash": "^4.17.15",
    "mapbox-gl": "^1.2.0",
    "next": "^8.1.0",
    "next-compose-plugins": "^2.2.0",
    "next-fonts": "^0.17.0",
    "next-images": "^1.1.2",
    "next-redux-wrapper": "^3.0.0-alpha.3",
    "nouislider-react": "^3.3.1",
    "react": "^16.8.6",
    "react-bootstrap": "^1.0.0-beta.9",
    "react-bootstrap-sidebar": "^0.0.1",
    "react-dom": "^16.8.6",
    "react-horizontal-timeline": "^1.5.3",
    "react-map-gl": "^5.0.3",
    "react-redux": "^7.1.0",
    "react-with-styles": "^3.2.3",
    "reactstrap": "^8.0.0",
    "redux": "^4.0.1",
    "redux-devtools-extension": "^2.13.8",
    "redux-thunk": "^2.3.0",
    "rheostat": "^3.0.2",
    "styled-components": "^4.2.1",
    "styled-components-breakpoint": "^2.1.1",
    "styled-components-modifiers": "^1.2.4"
  },
  "devDependencies": {
    "babel-plugin-styled-components": "^1.10.6",
    "dotenv-webpack": "^1.7.0"
  }
}

一切都很好,我的任何配置都没有看到任何问题。但这是我运行 yarn dev 时遇到的错误。Linuxubuntu服务器中已经安装了纱线 Ubuntu 16.04.6(LTS)x64 ,因为我已经使用它来管理同一服务器上 API 的软件包。 这是我运行 yarn dev 时遇到的错误:

yarn run v1.17.3
$ next
[ wait ]  starting the development server ...
[ info ]  waiting on http://localhost:3000 ...
[ error ] ./pages/_app.js
Error: Cannot find module 'babel-plugin-styled-components' from '/home/jochri3/projet-infrastructures/infrastructure-map'
- If you want to resolve "styled-components", use "module:styled-components"
    at Array.map (<anonymous>)
[ wait ]  compiling ...
[ error ] ./pages/_app.js
Error: Cannot find module 'babel-plugin-styled-components' from '/home/jochri3/projet-infrastructures/infrastructure-map'
- If you want to resolve "styled-components", use "module:styled-components"
    at Array.map (<anonymous>)

克隆存储库后,我已经完成了yarn install

我该如何解决这个问题? 谢谢

0 个答案:

没有答案