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.

Can't import js file in parent folder

See original GitHub issue

Description

Can’t import js file in parent folder

Reproduction

import {ReactNativeCron} from ‘…/ReactNativeCron’ gives error: Directory /Users/nikos/WebstormProjects/react-native-cron/ReactNativeCron doesn't exist

If I move the file to ./ReactNativeCron it works

  • React Native version: “react-native”: “0.40.0”

  • Platform: iOS

  • Operating System:MacOS

see https://github.com/QuantumInformation/react-native-cron/commit/ea7fdf2b2d8e280d630baf855da4b4d888772195

Issue Analytics

  • State:closed
  • Created 7 years ago
  • Comments:33 (2 by maintainers)

github_iconTop GitHub Comments

18reactions
gensc004commented, May 11, 2017

@hnryjms and I ran in to this as well. It is an issue for us because our react-native app is a subdirectory of our repo that contains a web app and server code. We have a lib directory that contains useful JS code for all projects, and would like to be able to use it everywhere. We could make the lib directory a local NPM module and install it into both projects, but that makes local development somewhat annoying.

The solution we found was to add the file called rn-cli.config.js at the Mobile app’s root which is the default file the react-native packager looks at for specifying run configurations.

const Path = require('path');

module.exports = {
    getProjectRoots: () => [ __dirname, Path.join(__dirname, "..") ]
};
15reactions
quantuminformationcommented, Jul 12, 2017

Can someone reopen this ticket?

Read more comments on GitHub >

github_iconTop Results From Across the Web

import files from parent/other directory in react - Stack Overflow
I want to import images from the images folder but I ran into an error Module not found: Error: Can't resolve '../assets/images/Web_SVG.svg'. My ......
Read more >
Import From Parent Folder · Python Cook Book
When a module named spam is imported, the interpreter first searches for a built-in module with that name. If not found, it then...
Read more >
import - JavaScript - MDN Web Docs - Mozilla
The static import declaration is used to import read-only live bindings which are exported by another module. The imported bindings are ...
Read more >
Documentation - Module Resolution - TypeScript
A relative import is resolved relative to the importing file and cannot resolve ... Ask the folder /root/src/moduleB if it contains a file...
Read more >
Python — How to Import Modules From Another Folder? - Finxter
For example, a module in the parent folder would be imported with from .. import module . The __init__.py file signals to Python...
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