New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Plugin/Preset files are not allowed to export objects, only functions #8707

Closed
freshcoderchan opened this Issue Sep 13, 2018 · 13 comments

Comments

Projects
None yet
4 participants
@freshcoderchan

freshcoderchan commented Sep 13, 2018

Hello.
I am getting this error.
I have seen that there is already about this error.
I have tried all but not working now.

This is package.json file

  "dependencies": {
    "@babel/core": "^7.0.1",
    "babel-loader": "^8.0.2",
    "babel-preset-es2015": "^6.24.1",
    "babel-preset-react": "^6.24.1",
    "webpack": "^4.18.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.8"
  },
  "devDependencies": {
    "@babel/preset-react": "^7.0.0"
  }

This is error what I am getting

ERROR in ./main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error: Plugin/Preset files are not allowed to export objects, only functions. In C:\Project\React\App_v1\node_modules\babel-preset-es2015\lib\index.js
@babel-bot

This comment has been minimized.

Show comment
Hide comment
@babel-bot

babel-bot Sep 13, 2018

Collaborator

Hey @freshcoderchan! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

Collaborator

babel-bot commented Sep 13, 2018

Hey @freshcoderchan! We really appreciate you taking the time to report an issue. The collaborators
on this project attempt to help as many people as possible, but we're a limited number of volunteers,
so it's possible this won't be addressed swiftly.

If you need any help, or just have general Babel or JavaScript questions, we have a vibrant Slack
community that typically always has someone willing to help. You can sign-up here
for an invite.

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo Sep 13, 2018

Member

You need to update babel-preset-es2015 to Babel 7. (Actually, the preferred way is to use the @babel/preset-env preset).
Also, you shouldn't use babel-preset-react but only @babel/preset-react.

If these changes doesn't fix your problem, please post your Babel and webpack config.

Member

nicolo-ribaudo commented Sep 13, 2018

You need to update babel-preset-es2015 to Babel 7. (Actually, the preferred way is to use the @babel/preset-env preset).
Also, you shouldn't use babel-preset-react but only @babel/preset-react.

If these changes doesn't fix your problem, please post your Babel and webpack config.

@freshcoderchan

This comment has been minimized.

Show comment
Hide comment
@freshcoderchan

freshcoderchan Sep 13, 2018

Hello, @nicolo-ribaudo
Thanks.

This is package.json file

"dependencies": {
    "@babel/core": "^7.0.1",
    "@babel/preset-env": "^7.0.0",
    "babel-loader": "^8.0.2",
    "webpack": "^4.18.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.8"
  },

This webpack.config.js file.

var config = {
	entry: './main.js',
	output: {
		path: __dirname + '/',
		filename: 'index.js',
	},
	devServer: {
		inline: true,
		port: 8080
	},
	module: {
		rules: [
			{
				test: /\.jsx?$/,
				exclude: /node_modules/,
				use: {
					loader: 'babel-loader',
				},
			}
		]
	}
};

module.exports = config;

This is babel config file.

{
    "presets": ["@babel/preset-env"]
}

I have installed @babel/preset-react.
so I am having this error now.

ERROR in ./main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Project\React\App_v1\main.js: Unexpected token (5:16)

  3 | import App from './App.jsx';
  4 |
> 5 | ReactDOM.render(<App />, document.getElementById('app'));

I am not sure what I am wrong.
Can you help me?

freshcoderchan commented Sep 13, 2018

Hello, @nicolo-ribaudo
Thanks.

This is package.json file

"dependencies": {
    "@babel/core": "^7.0.1",
    "@babel/preset-env": "^7.0.0",
    "babel-loader": "^8.0.2",
    "webpack": "^4.18.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.8"
  },

This webpack.config.js file.

var config = {
	entry: './main.js',
	output: {
		path: __dirname + '/',
		filename: 'index.js',
	},
	devServer: {
		inline: true,
		port: 8080
	},
	module: {
		rules: [
			{
				test: /\.jsx?$/,
				exclude: /node_modules/,
				use: {
					loader: 'babel-loader',
				},
			}
		]
	}
};

module.exports = config;

This is babel config file.

{
    "presets": ["@babel/preset-env"]
}

I have installed @babel/preset-react.
so I am having this error now.

ERROR in ./main.js
Module build failed (from ./node_modules/babel-loader/lib/index.js):
SyntaxError: C:\Project\React\App_v1\main.js: Unexpected token (5:16)

  3 | import App from './App.jsx';
  4 |
> 5 | ReactDOM.render(<App />, document.getElementById('app'));

I am not sure what I am wrong.
Can you help me?

@existentialism

This comment has been minimized.

Show comment
Hide comment
@existentialism

existentialism Sep 14, 2018

Member

@freshcoderchan you'll want to add @babel/preset-react as well.

Member

existentialism commented Sep 14, 2018

@freshcoderchan you'll want to add @babel/preset-react as well.

@freshcoderchan

This comment has been minimized.

Show comment
Hide comment
@freshcoderchan

freshcoderchan Sep 14, 2018

I have tried to add @babel/preset-react, but it didn't help me.
My OS is Windows 10, so maybe is this problem?

freshcoderchan commented Sep 14, 2018

I have tried to add @babel/preset-react, but it didn't help me.
My OS is Windows 10, so maybe is this problem?

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo Sep 14, 2018

Member

Are you stil gettnig the same error?
Is your .babelrc like this:

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ]
}

My OS is Windows 10, so maybe is this problem?

Babel should work on any OS that supports node.

Member

nicolo-ribaudo commented Sep 14, 2018

Are you stil gettnig the same error?
Is your .babelrc like this:

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ]
}

My OS is Windows 10, so maybe is this problem?

Babel should work on any OS that supports node.

@freshcoderchan

This comment has been minimized.

Show comment
Hide comment
@freshcoderchan

freshcoderchan Sep 14, 2018

Yes, still have error.

freshcoderchan commented Sep 14, 2018

Yes, still have error.

@nicolo-ribaudo

This comment has been minimized.

Show comment
Hide comment
@nicolo-ribaudo

nicolo-ribaudo Sep 14, 2018

Member

What do DEBUG=babel:config:loading:files:configuration [write here the command you are using to build your project] and DEBUG=babel:config:loading:files:plugins [write here the command you are using to build your project] log?

Member

nicolo-ribaudo commented Sep 14, 2018

What do DEBUG=babel:config:loading:files:configuration [write here the command you are using to build your project] and DEBUG=babel:config:loading:files:plugins [write here the command you are using to build your project] log?

@freshcoderchan

This comment has been minimized.

Show comment
Hide comment
@freshcoderchan

freshcoderchan Sep 14, 2018

This is my package.json file.

  "dependencies": {
    "@babel/core": "^7.0.1",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.2",
    "webpack": "^4.18.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.8"
  },

This is my babel config file.

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ]
}

I am getting this different error:

ERROR in ./main.js
Module not found: Error: Can't resolve 'react' in 'C:\Project\React\App_v1'
 @ ./main.js 1:0-26 4:16-21
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./main.js

ERROR in ./App.jsx
Module not found: Error: Can't resolve 'react' in 'C:\Project\React\App_v1'
 @ ./App.jsx 19:0-26 35:13-18 40:2-7
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./main.js

ERROR in ./main.js
Module not found: Error: Can't resolve 'react-dom' in 'C:\Project\React\App_v1'
 @ ./main.js 2:0-33 4:0-8
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./main.js
i 「wdm」: Failed to compile.

Can you tell me why I have different error now?

freshcoderchan commented Sep 14, 2018

This is my package.json file.

  "dependencies": {
    "@babel/core": "^7.0.1",
    "@babel/preset-env": "^7.0.0",
    "@babel/preset-react": "^7.0.0",
    "babel-loader": "^8.0.2",
    "webpack": "^4.18.1",
    "webpack-cli": "^3.1.0",
    "webpack-dev-server": "^3.1.8"
  },

This is my babel config file.

{
    "presets": [
        "@babel/preset-env",
        "@babel/preset-react"
    ]
}

I am getting this different error:

ERROR in ./main.js
Module not found: Error: Can't resolve 'react' in 'C:\Project\React\App_v1'
 @ ./main.js 1:0-26 4:16-21
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./main.js

ERROR in ./App.jsx
Module not found: Error: Can't resolve 'react' in 'C:\Project\React\App_v1'
 @ ./App.jsx 19:0-26 35:13-18 40:2-7
 @ ./main.js
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./main.js

ERROR in ./main.js
Module not found: Error: Can't resolve 'react-dom' in 'C:\Project\React\App_v1'
 @ ./main.js 2:0-33 4:0-8
 @ multi (webpack)-dev-server/client?http://localhost:8080 (webpack)/hot/dev-server.js ./main.js
i 「wdm」: Failed to compile.

Can you tell me why I have different error now?

@freshcoderchan

This comment has been minimized.

Show comment
Hide comment
@freshcoderchan

freshcoderchan Sep 14, 2018

I have used npm start command to run project.

freshcoderchan commented Sep 14, 2018

I have used npm start command to run project.

@existentialism

This comment has been minimized.

Show comment
Hide comment
@existentialism

existentialism Sep 14, 2018

Member

@freshcoderchan I think you need to include react, react-dom in your package.json as well.

Member

existentialism commented Sep 14, 2018

@freshcoderchan I think you need to include react, react-dom in your package.json as well.

@freshcoderchan

This comment has been minimized.

Show comment
Hide comment
@freshcoderchan

freshcoderchan Sep 14, 2018

Thanks @existentialism 👍
It works now.
Thanks @nicolo-ribaudo 👍

freshcoderchan commented Sep 14, 2018

Thanks @existentialism 👍
It works now.
Thanks @nicolo-ribaudo 👍

@existentialism

This comment has been minimized.

Show comment
Hide comment
@existentialism
Member

existentialism commented Sep 14, 2018

@freshcoderchan glad to hear!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment