Build Failing To Identify CommonJS Modules

Briefly summarize the issues you have been experiencing.
I’m trying to publish a staging version of my gatsby site to netlify. Everything is building fine on my computer, but when I run my build in netlify I get errors where all of my absolute imports cannot be seen, such as “Error: ./src/views/api/style.ts
Module not found: Error: Can’t resolve ‘./section/index’ in ‘/opt/build/repo/s rc/views/api’
resolve ‘./section/index’ in ‘/opt/build/repo/src/views/api’”
all of my file names are lowercase, it seems to have trouble recognizing my absolute imports and commonjs style imports from index.ts files
any guidance you could provide would be appreciated

Please provide a link to your live site hosted on Netlify
https://horizon.mothership.build/

What have you tried as far as troubleshooting goes? Do you have an idea what is causing the problem?
I’ve tried debugging Gatsby issues such as changing settings for the root import plugins, changing the names of all the files in my projects, and messing w the build settings. Nothing works.

Do you have any other information that is relevant, such as links to docs, libraries, or other resources?
I’m using Gatsby.js, and everything is working locally, can’t figure out what’s going on.

Here’s my total printout of the errors in the terminal:
2:54:45 PM: Error: ./src/views/api/style.ts
2:54:45 PM: Module not found: Error: Can’t resolve ‘./section/index’ in ‘/opt/build/repo/s rc/views/api’
2:54:45 PM: resolve ‘./section/index’ in ‘/opt/build/repo/src/views/api’
2:54:45 PM: using description file: /opt/build/repo/package.json (relative path: ./src/v iews/api)
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: using description file: /opt/build/repo/package.json (relative path: ./src /views/api/section/index)
2:54:45 PM: no extension
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index doesn’t exist
2:54:45 PM: .mjs
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.mjs doesn’t exist
2:54:45 PM: .js
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.js doesn’t exist
2:54:45 PM: .jsx
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.jsx doesn’t exist
2:54:45 PM: .wasm
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.wasm doesn’t exist
2:54:45 PM: .json
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.json doesn’t exist
2:54:45 PM: .ts
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.ts doesn’t exist
2:54:45 PM: .tsx
2:54:45 PM: Field ‘browser’ doesn’t contain a valid alias configuration
2:54:45 PM: /opt/build/repo/src/views/api/section/index.tsx doesn’t exist
2:54:45 PM: as directory
2:54:45 PM: /opt/build/repo/src/views/api/section/index doesn’t exist
2:54:45 PM: [/opt/build/repo/src/views/api/section/index]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.mjs]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.js]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.jsx]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.wasm]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.json]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.ts]
2:54:45 PM: [/opt/build/repo/src/views/api/section/index.tsx]
2:54:45 PM: @ ./src/views/api/style.ts 15:0-38 31:34-41
2:54:45 PM: @ ./src/views/api/index.tsx
2:54:45 PM: @ ./src/pages/api/index.tsx
2:54:45 PM: @ ./.cache/async-requires.js
2:54:45 PM: @ ./.cache/production-app.js

Hi again Justin!

Hoping to hear how the experiments I coached you in in the helpdesk turned out? I see some successful builds on that site so I guess you did find a resolution yesterday, but of course happy to keep guiding you in debugging if I guessed wrong.

Hi

This seems to be very similar to my issue. What’s is the solution to it?

Here’s my error output:
Error: ./node_modules/sqrl-design-system/dist/Switch.js
3:19:27 AM: Module not found: Error: Can’t resolve ‘react-switch’ in ‘/opt/build/repo/node _modules/sqrl-design-system/dist’
3:19:27 AM: resolve ‘react-switch’ in ‘/opt/build/repo/node_modules/sqrl-design-system/dis t’
3:19:27 AM: Parsed request is a module
3:19:27 AM: using description file: /opt/build/repo/node_modules/sqrl-design-system/pack age.json (relative path: ./dist)
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: resolve as module
3:19:27 AM: /opt/build/repo/node_modules/sqrl-design-system/dist/node_modules doesn’ t exist or is not a directory
3:19:27 AM: /opt/build/repo/node_modules/sqrl-design-system/node_modules doesn’t exi st or is not a directory
3:19:27 AM: /opt/build/repo/node_modules/node_modules doesn’t exist or is not a dire ctory
3:19:27 AM: /opt/build/node_modules doesn’t exist or is not a directory
3:19:27 AM: /opt/node_modules doesn’t exist or is not a directory
3:19:27 AM: /node_modules doesn’t exist or is not a directory
3:19:27 AM: looking for modules in /opt/build/repo/node_modules
3:19:27 AM: using description file: /opt/build/repo/package.json (relative path: . /node_modules)
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: using description file: /opt/build/repo/package.json (relative path: ./node_modules/react-switch)
3:19:27 AM: no extension
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: /opt/build/repo/node_modules/react-switch doesn’t exist
3:19:27 AM: .mjs
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: /opt/build/repo/node_modules/react-switch.mjs doesn’t exist
3:19:27 AM: .js
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: /opt/build/repo/node_modules/react-switch.js doesn’t exist
3:19:27 AM: .jsx
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: /opt/build/repo/node_modules/react-switch.jsx doesn’t exist
3:19:27 AM: .wasm
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: /opt/build/repo/node_modules/react-switch.wasm doesn’t exist
3:19:27 AM: .json
3:19:27 AM: Field ‘browser’ doesn’t contain a valid alias configuration
3:19:27 AM: /opt/build/repo/node_modules/react-switch.json doesn’t exist
3:19:27 AM: as directory
3:19:27 AM: /opt/build/repo/node_modules/react-switch doesn’t exist
3:19:27 AM: [/opt/build/repo/node_modules/sqrl-design-system/dist/node_modules]
3:19:27 AM: [/opt/build/repo/node_modules/sqrl-design-system/node_modules]
3:19:27 AM: [/opt/build/repo/node_modules/node_modules]
3:19:27 AM: [/opt/build/node_modules]
3:19:27 AM: [/opt/node_modules]
3:19:27 AM: [/node_modules]
3:19:27 AM: [/opt/build/repo/node_modules/react-switch]
3:19:27 AM: [/opt/build/repo/node_modules/react-switch.mjs]
3:19:27 AM: [/opt/build/repo/node_modules/react-switch.js]
3:19:27 AM: [/opt/build/repo/node_modules/react-switch.jsx]
3:19:27 AM: [/opt/build/repo/node_modules/react-switch.wasm]
3:19:27 AM: [/opt/build/repo/node_modules/react-switch.json]
3:19:27 AM: @ ./node_modules/sqrl-design-system/dist/Switch.js 4:0-34 5:45-51
3:19:27 AM: @ ./node_modules/sqrl-design-system/dist/index.js
3:19:27 AM: @ ./src/pages/demo.jsx
3:19:27 AM: @ ./.cache/async-requires.js
3:19:27 AM: @ ./.cache/production-app.js

@akarsh is your repo public? if so, please provide a link to it. Also provide a link to one of your failing builds. Lastly, is the npm install and build working normally on your local machine?

Hi
Our main repo is private so i can’t get you a link for that, but this repo uses another repo as a package which is public (https://github.com/mokko-labs/sqrl-design-system) and also the source of the problem.

Link for failing build: https://app.netlify.com/sites/youthful-beaver-e12d80/deploys/5d48a404da4a1b9e227f2eaf

The site uses Gatsby. npm install, gatsby develop and gatsby build work perfectly on local.

thanks for the link to your build! I think your problem is with case sensitivity, and sorry we didn’t notice this at first:

2:49:27 PM: Error: ./node_modules/sqrl-design-system/dist/Switch.js

On our unix-based build system, Switch.js is not the same as switch.js . On your local system, I suspect they resolve to the same file.

I’d standardize on lowercase in both your files on disk AND in your includes of them, since npm installations are by default all in lowercase.