我試圖在webpack項目中使用googleapis。每當我調用Webpack和GoogleApis端點路徑問題
static getApi =() => {
google.sheets('v4');
}
我得到的googleapis/lib/googleapis.js
線50,這基本上是var Endpoint = require(endpointPath);
以下Error: Unable to load endpoint ../apis/sheets("v4"): Cannot find module "."
起源。
我試圖尋找到endpointPath,但它恰好是正確的:node_modules/googleapis/apis/sheets/v4
我webpack.config.js的介紹如下:
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'
}
卸下
node: {
__dirname: true
},
導致獲得來自上述googleapis.js的第62行的ENOENT: no such file or directory, scandir '/apis'
您是否找到解決此問題的解決方案? – shashi