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.

Failed to Compile w/ Absolute Import Paths v1.2.0

See original GitHub issue

Hi,

I followed the quick start and terminal commands instructions from the Readme and am getting a failed to compile error due modules being unable to resolve. When I change the import statements to use relative paths the modules do resolve:

For example, with absolute path: import "assets/css/material-dashboard-react.css?v=1.2.0"; // Compile Error

Changing to relative path: import "./assets/css/material-dashboard-react.css?v=1.2.0"; // Module is resolved properly

screenshot from 2018-04-21 12-01-45

I saw the .env file does specify the NODE_PATH environment variable, but cannot get absolute paths to work on import statements;

Thanks!

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Reactions:1
  • Comments:13 (5 by maintainers)

github_iconTop GitHub Comments

11reactions
einazarecommented, Apr 24, 2018

Hello @marciandmnd ,

You can solve this issue by changing the start script from:

"start": "react-scripts start",

to

"start": "NODE_PATH=./src react-scripts start",

and also you will need to install cross-env globally on your machine

npm install --g cross-env

Best, Manu

2reactions
einazarecommented, May 23, 2019

A better solution is to create a jsconfig.json file with this code inside it:

{
  "compilerOptions": {
    "baseUrl": "src",
    "paths": {
      "*": ["src/*"]
    }
  }
}

All of our React products will have this file in the next updates.

Best, Manu ReactJS Developer

Read more comments on GitHub >

github_iconTop Results From Across the Web

Cannot get the absolute paths working in typescript nodejs ...
The VSCode intellisense is able to resolve the absolute import paths fine, but when I compile, I get compilation error. Note: relative paths...
Read more >
Import-Module (Microsoft.PowerShell.Core)
The Import-Module cmdlet adds one or more modules to the current session. ... Starting in Windows PowerShell 3.0, you can use Import-Module to...
Read more >
Module Resolution - webpack
A resolver is a library which helps in locating a module by its absolute path. A module can be required as a dependency...
Read more >
tsc-alias - npm
Replace alias paths with relative paths after typescript compilation. ... tsconfig.json project by providing a relative path to the baseUrl.
Read more >
Documentation - Module Resolution - TypeScript
ts. For non-relative module imports, however, the compiler walks up the directory tree starting with the directory containing the importing file, trying to ......
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