Reputation: 111
On my ruby project when I try to run gulp (gulp server, gulp watch) I have the following error :
Users/workspace/website2019/gulpfile.babel.js:1
import del from 'del';
^^^^^^
SyntaxError: Cannot use import statement outside a module
I don't get how can I fix it, if someone could help me please,
Upvotes: 5
Views: 9693
Reputation: 77
make sure you have this line in package.json
"type": "module"
Upvotes: 6
Reputation: 96
you use babel transpilation with gulp because of the file gulpfile.babel.js
For this reason you need to install babel. according to the documentation you need @babel/register
and @babel/preset-env
for transpiling your import
syntax.
So run the following command in your project folder
npm install --save-dev @babel/core @babel/register
Afterwards create the babel configuration file .babelrc
in the root folder and add the following lines to it
{
"presets": [
[
"@babel/preset-env",
{
"targets": {
"node": "current"
}
}
]
]
}
Upvotes: 4