Skip to content
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

Module not found: Can't resolve 'xlsx' in 'filelocation\node_modules\cptable-fixed-xlsx-style' #165

Open
kameshdhana opened this issue Mar 8, 2022 · 0 comments

Comments

@kameshdhana
Copy link

We have tried ServerSideRendering for our web application, so we acheived it using ( https://github.com/axeldelafosse/expo-next-monorepo-example ) custom mono-repo-application which will support both node and next js. While running my build command I am facing this can't resolve xlsx error in cptable-fixed-xlsx-style package.

I'm using nextjs latest version 12 and webpack 5 & cptable-fixed-xlsx-style 0.8.20

Error message in terminal:
../../node_modules/cptable-fixed-xlsx-style/ods.js
Module not found: Can't resolve 'xlsx' in 'filelocation\node_modules\cptable-fixed-xlsx-style'
Did you mean './xlsx'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.

Import trace for requested module:
../../node_modules/cptable-fixed-xlsx-style/xlsx.js
../app/src/components/Applications/Tabs/CreditTransactions.tsx
../app/LoanManagementApp.tsx
../app/App.tsx
./src/pages/index.tsx

We have tried ServerSideRendering for our web application, so we acheived it using ( https://github.com/axeldelafosse/expo-next-monorepo-example ) custom mono-repo-application which will support both node and next js. While running my build command I am facing this can't resolve xlsx error in cptable-fixed-xlsx-style package.

I'm using nextjs latest version 12 and webpack 5 & cptable-fixed-xlsx-style 0.8.20

Erorr message in terminal:

../../node_modules/cptable-fixed-xlsx-style/ods.js
Module not found: Can't resolve 'xlsx' in 'filelocation\node_modules\cptable-fixed-xlsx-style'
Did you mean './xlsx'?
Requests that should resolve in the current directory need to start with './'.
Requests that start with a name are treated as module requests and resolve within module directories (node_modules).
If changing the source code is not an option there is also a resolve options called 'preferRelative' which tries to resolve these kind of requests in the current directory too.

Import trace for requested module:
../../node_modules/cptable-fixed-xlsx-style/xlsx.js
../app/src/components/Applications/Tabs/CreditTransactions.tsx
../app/LoanManagementApp.tsx
../app/App.tsx
./src/pages/index.tsx

Our next.config.js:
// @ts-check

/**

  • @type {import('next').NextConfig}
    **/

require('events').EventEmitter.defaultMaxListeners = Infinity;

const { withExpo } = require('@expo/next-adapter')
const withPlugins = require('next-compose-plugins')
const withFonts = require('next-fonts')
const withBundleAnalyzer = require('@next/bundle-analyzer')({
enabled: process.env.ANALYZE === 'true'
})
const withTM = require('next-transpile-modules')([
'app',
'@gorhom/bottom-sheet',
'@gorhom/portal',
'dripsy',
'@dripsy/core',
'recyclerlistview'
])

const nextConfig = {
typescript: {
ignoreBuildErrors: true,
},
compress: true,
webpack: (config) => {
config.resolve.fallback = { fs: false };

return config;

},
}

module.exports = withPlugins(
[
withTM,
withFonts,
withBundleAnalyzer,
[withExpo, { projectRoot: __dirname + '/../..' }]
],
nextConfig
)

../../node_modules/cptable-fixed-xlsx-style/ods.js

/* ods.js (C) 2014 SheetJS -- http://sheetjs.com /
/
vim: set ts=2: */
/*jshint -W041 /
var ODS = {};
(function make_ods(ODS) {
/
Open Document Format for Office Applications (OpenDocument) Version 1.2 */
var get_utils = function() {
if(typeof XLSX !== 'undefined') return XLSX.utils;
if(typeof module !== "undefined" && typeof require !== 'undefined') try {
return require('../' + 'xlsx').utils;
} catch(e) {
try { return require('./' + 'xlsx').utils; }
catch(ee) { return require('xl' + 'sx').utils; }
}
throw new Error("Cannot find XLSX utils");
};

Is there any fix for this?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant