4

I'm attempting to run a strapi project via npm on Ubuntu 20.04 with "npm run develop". The code is from a group project of mine, and no one else is encountering these issues.

Error: ./.cache/plugins/strapi-plugin-content-manager/admin/src/components/RepeatableComponent/Banner.js 2:87
Module parse failed: Unexpected token (2:87)
File was processed with these loaders:
 * ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.

I've attempted the solutions on these threads: Strapi develop command failed, How to fix "Module build failed (from ./node_modules/babel-loader/lib/index.js):"?

Neither of which have worked.

I've also attempted:

  • Reinstalling Ubuntu
  • Reinstalling Babel
  • Downgrading or trying different versions of Babel

Here's my project's package.json, which should hopefully provide more context

{
  "name": "my-project",
  "private": true,
  "version": "0.1.0",
  "description": "A Strapi application",
  "scripts": {
    "develop": "strapi develop",
    "start": "strapi start",
    "build": "strapi build",
    "strapi": "strapi"
  },
  "devDependencies": {
    "@babel/core": "^7.13.15",
    "@babel/preset-env": "^7.13.15",
    "babel-loader": "^8.2.2",
    "webpack": "^5.33.2"
  },
  "dependencies": {
    "knex": "0.21.18",
    "sqlite3": "5.0.0",
    "strapi": "3.5.4",
    "strapi-admin": "3.5.4",
    "strapi-connector-bookshelf": "3.5.4",
    "strapi-plugin-content-manager": "3.5.4",
    "strapi-plugin-content-type-builder": "3.5.4",
    "strapi-plugin-email": "3.5.4",
    "strapi-plugin-graphql": "3.5.4",
    "strapi-plugin-upload": "3.5.4",
    "strapi-plugin-users-permissions": "3.5.4",
    "strapi-utils": "3.5.4"
  },
  "author": {
    "name": "A Strapi developer"
  },
  "strapi": {
    "uuid": "ab32cbf0-3e4d-42ea-a078-e816435ef1f7"
  },
  "engines": {
    "node": ">=10.16.0 <=14.x.x",
    "npm": "^6.0.0"
  },
  "license": "MIT"
}

Am I just improperly using my package.json file? Any tips or direction would be greatly appreciated.

1 Answer 1

3

1. Better solution.

Check if your Strapi project is nested within another project that uses babel/webpack. I had some old files in my directory with all my projects. When I removed them, it works.

2. Workaround solution (With every packages update, it will be back to an earlier version)

  1. in your strapi folder, go to → node_modules/strapi-admin/webpack.config.js
  2. locate the line → require.resolve('@babel/preset-env')
  3. replace it with [require.resolve('@babel/preset-env'),{ targets: 'defaults' }],
  4. run the command - npm run dev
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.