Answer the question
In order to leave comments, you need to log in
How to fix ERROR in wpapi.js Module parse failed You may need an appropriate loader to handle this file type?
Hello!
When installing npm modules I get an error when building webpack
ERROR in ./~/wpapi/wpapi.js Module parse failed: C:\Users...\decoupled\node_modules\wpapi\wpapi.js Unexpected token (235:2) You may need an appropriate loader to handle this file type . | WPAPI.prototype.url = function( url ) { |
return new WPRequest( { | ...this._options, |
endpoint: url, | } ); @ ./src/lib/config.js 1:0-26 @ ./src/components/Menu/Index.js @ ./src/App.js @ multi (webpack)-dev-server/client? https://localhost:9000 ./src/App.js webpack: Failed to compile.
{
"name": "node-wpapi",
"version": "1.0.0",
"description": "Example of using the Node JavaScript WP API Client - https://github.com/WP-API/node-wpapi",
"main": "src/index.js",
"scripts": {
"start": "webpack-dev-server --https",
"build": "webpack --config webpack.config.js"
},
"keywords": [],
"author": "Zac Gordon",
"license": "ISC",
"devDependencies": {
"babel-cli": "^6.24.1",
"babel-core": "^6.22.1",
"babel-loader": "^6.2.10",
"babel-preset-es2015": "^6.22.0",
"uglifyjs-webpack-plugin": "^0.1.4",
"webpack": "^2.2.1",
"webpack-dev-server": "^2.4.1"
},
"dependencies": {
"wpapi": "^1.0.3"
}
}
var path = require( 'path' );
var UglifyJSPlugin = require( 'uglifyjs-webpack-plugin' );
module.exports = {
entry: [ './src/App.js' ],
output: {
filename: 'bundle.min.js',
path: path.resolve( __dirname, 'dist' )
},
devtool: "cheap-eval-source-map",
devServer: {
port: 9000,
contentBase: path.join( __dirname, "dist" )
},
module: {
rules: [{
test: /\.js$/,
exclude: /(node_modules)/,
use: [ {
loader: 'babel-loader',
options: {
presets: [ [ 'es2015', { modules: false } ] ]
}
} ]
}]
},
plugins: [
new UglifyJSPlugin()
]
};
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question