question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Error: Cannot find module '@linaria/core/processors/BaseProcessor' when building node version in devmode

See original GitHub issue

Environment

webpack config has:

    config.externals = [
      nodeExternals({
        additionalModuleDirs: ['../../node_modules'],
        allowlist: [
          /^@anansi\/core\/server/,
          /^path-to-regexp/,
          /\.css$/,
        ],
      }),
    ];

Building for server side

  • Linaria version: 3.0.0-beta.20
  • Bundler (+ version): webpack 5.73.0
  • Node.js version: v16.15.0
  • OS: ubuntu 20.04

Description

ModuleBuildError: Module build failed (from ../../node_modules/@linaria/webpack5-loader/lib/index.js):
Error: Cannot find module '@linaria/core/processors/BaseProcessor'
Require stack:
- /home/ntucker/src/anansi/node_modules/@linaria/babel-preset/lib/utils/getTagProcessor.js
- /home/ntucker/src/anansi/node_modules/@linaria/babel-preset/lib/utils/replaceTagWithValue.js
- /home/ntucker/src/anansi/node_modules/@linaria/babel-preset/lib/index.js
- /home/ntucker/src/anansi/node_modules/@linaria/webpack5-loader/lib/index.js
- /home/ntucker/src/anansi/node_modules/loader-runner/lib/loadLoader.js
- /home/ntucker/src/anansi/node_modules/loader-runner/lib/LoaderRunner.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/NormalModuleFactory.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/Compiler.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/webpack.js
- /home/ntucker/src/anansi/packages/core/node_modules/webpack/lib/index.js
- /home/ntucker/src/anansi/packages/core/lib/scripts/startDevserver.js
- /home/ntucker/src/anansi/packages/core/lib/scripts/index.js
    at Function.Module._resolveFilename (node:internal/modules/cjs/loader:933:15)
    at Function.Module._load (node:internal/modules/cjs/loader:778:27)
    at Module.require (node:internal/modules/cjs/loader:1005:19)
    at require (node:internal/modules/cjs/helpers:102:18)
    at Object.<anonymous> (/home/ntucker/src/anansi/node_modules/@linaria/babel-preset/src/utils/getTagProcessor.ts:9:1)
    at Module._compile (node:internal/modules/cjs/loader:1105:14)
    at Module._compile (/home/ntucker/src/anansi/node_modules/source-map-support/source-map-support.js:568:25)
    at Object.Module._extensions..js (/home/ntucker/src/anansi/node_modules/fs-monkey/lib/patchRequire.js:141:12)
    at Module.load (node:internal/modules/cjs/loader:981:32)
    at Function.Module._load (node:internal/modules/cjs/loader:822:12)
{
    request: '/home/ntucker/src/anansi/node_modules/babel-loader/lib/index.js??ruleSet[1].rules[0].oneOf[1].use[0]!/home/ntucker/src/anansi/node_modules/@linaria/webpack5-loader/lib/index.js??ruleSet[1].rules[0].oneOf[1].use[1]!/home/ntucker/src/anansi/examples/concurrent/src/index.server.tsx',
    userRequest: '/home/ntucker/src/anansi/examples/concurrent/src/index.server.tsx',
    rawRequest: './src/index.server.tsx',
}

Note: yarn build (building client production) and yarn build:server (building server production) both work. It’s the webpack-dev-server build for node that doesn’t work.

Reproducible Demo

https://github.com/ntucker/anansi/tree/c85f2c42602fda03594966eb7a2b90d3e45cfd4e

  1. git clone https://github.com/ntucker/anansi
  2. git checkout c85f2c42602fda03594966eb7a2b90d3e45cfd4e
  3. yarn install
  4. yarn build:pkg
  5. cd examples/concurrent
  6. yarn start

Issue Analytics

  • State:closed
  • Created a year ago
  • Reactions:1
  • Comments:17

github_iconTop GitHub Comments

1reaction
ntuckercommented, Jun 9, 2022

For anyone stumbling on this thread, I was able to solve require() compat by switching to fs-require from fs-monkey. https://github.com/ntucker/anansi/pull/1538

1reaction
Anbercommented, Jun 9, 2022

Released as 3.0.0-beta.21

Read more comments on GitHub >

github_iconTop Results From Across the Web

How do I resolve "Cannot find module" error using Node.js?
Using npm install installs the module into the current directory only (in a subdirectory called node_modules ). Is app.js located under ...
Read more >
cannot find module [Node npm Error Solved] - freeCodeCamp
I'll do that by running yarn add react-icons . Once I install the package and run the app, everything should successfully compile: ss2....
Read more >
Cannot find module 'node:path' in vite.config.ts · Issue #9113 ...
The error is Error: Cannot find module 'node:path' which seems to mean that the build isn't running in a node environment.
Read more >
node-fetch - npm
A light-weight module that brings Fetch API to node.js. Latest version: ... If you happen to use a missing feature that window.fetch offers, ......
Read more >
[Solution] Error: Cannot Find Module "nodemailer" - Courier
Please note that your Node.js version must be v6.0 or greater to install Nodemailer. After executing the npm command, your package.json will have ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found