I'm trying to use googleapis in a webpack project. Whenever I invoke
static getApi = () => {
google.sheets('v4');
}
I get the following Error: Unable to load endpoint ../apis/sheets("v4"): Cannot find module "." Originating from line 50 of googleapis/lib/googleapis.js, which is basically var Endpoint = require(endpointPath);.
I tried looking into endpointPath, but it happens to be the correct one: node_modules/googleapis/apis/sheets/v4
My webpack.config.js is presented below:
module.exports = {
entry: ['babel-polyfill','./src/index.js'],
target: 'async-node', // Improved performance in node version 6+
node: {
__dirname: true
},
output: {
filename: './dist/bundle.js',
libraryTarget: 'commonjs2'
},
module: {
rules: [
{
test: /\.(graphql|gql)$/,
exclude: /node_modules/,
loader: 'graphql-tag/loader'
},
{
test: /\.js$/,
exclude: /(node_modules)/,
use: {
loader: 'babel-loader',
options: {
presets: ['env'],
plugins: [require('babel-plugin-transform-class-properties')]
}
}
}
]
},
devtool: 'source-map'
}
Removing the
node: {
__dirname: true
},
results in getting a ENOENT: no such file or directory, scandir '/apis' originating from line 62 of the aforementioned googleapis.js
via Paolo Campanelli
No comments:
Post a Comment