Comments (17)
NODE_PATH is a deprecated feature.
Making flow support all possible nodejs specific hacks based on the internal interface of module
seems really complicated.
from flow.
how is NODE_PATH deprecated?
And I'm happy to change my implementation to whatever else if I still can require without having do require('../../../../../../../some/path');
from flow.
I think this issue can be closed after module.system.node.resolve_dirname
was added in 0.18.1.
Docs are scarce but check the .flowconfig
in the test in e1e301c to see how it's used.
from flow.
as @dmnd mentioned; for these too lazy to search through commit changes in .flowconfig
, this worked for me:
[options]
module.system.node.resolve_dirname=node_modules
module.system.node.resolve_dirname=src
from flow.
I mispoke. It was require.paths
that is deprecated. NODE_PATH is a feature in node that is still supported.
However the way your using the feature is not recommended. General wisdom in the node community is that if you find yourself doing "../../../../../../../some/path" you've written a very large application and should look into breaking it out over multiple npm packages and putting more code in node_modules.
It would make sense for flow to support NODE_PATH, i.e. NODE_PATH=x flow ...
if set from the cli, feature detecting for mutation of it in actual source code is a slippery slope of working on in only some cases and not all.
from flow.
@frontsideair look that. I finded decision problem
https://flow.org/en/docs/config/options/#toc-module-system-node-resolve-dirname-string
from flow.
@kirushi I was doing something very similar, but I discovered that actually can hide errors from you. See #5647 (comment) -- I switched to
module.name_mapper='^\(.*\)' -> '<PROJECT_ROOT>/src/\1'
from flow.
Thanks @dmnd. I think you're right that .flowconfig
option will solve the problem outlined here. We have a few features here that need to be documented, and we already have tasks to add that.
from flow.
And it's not just nodejs specific. Browserify is the most common commonjs bundler and it supports the NODE_PATH
hack too.
And I just happen to use an internal interface. If I would give NODE_PATH
outside of the script, then I wouldn't have to call module internal interfaces. IMO it would seem much wiser to build on top of require
(or the modules browserify uses) than to use some own implementation that clearly isn't doing at its current state a very good job (#49 for instance).
from flow.
+1 for NODE_PATH support
from flow.
+1
from flow.
Thank you for reporting this issue and appreciate your patience. We've notified the core team for an update on this issue. We're looking for a response within the next 30 days or the issue may be closed.
from flow.
I'm using nix
package manager to generate the environment, which installs node packages to a folder and sets the NODE_PATH
env var to that folder. We don't want to create a node_modules
symlink in the working directory so we're doing all sorts of crazy hacks to make it work.
If flow can check NODE_PATH
in addition to node_modules
in the working directory or it could accept a command line flag for resolve_dirname
, it would make our workflow much better.
from flow.
I hit this problem again, and it was weird to see my comment is the last thing on the issue. I hope this can be implemented.
from flow.
@frontsideair me to
from flow.
The settings below don't return any errors on flow (albeit there being many purposely placed errors)
.env
NODE_PATH=src/
.flowconfig
[options] module.system.node.resolve_dirname=node_modules module.system.node.resolve_dirname=src
from flow.
In my case works:
module.name_mapper='^\(.*\)' -> '<PROJECT_ROOT>/src/\1'
module.file_ext=.jsx
module.file_ext=.js
from flow.
Related Issues (20)
- Does not narrow down type after undefined/falsy check HOT 1
- Recursive/deep Partial HOT 2
- Bugs in negated `instanceof` expressions HOT 1
- [Question]: How to fix flowgen test after flow update HOT 3
- [Discussion]: Any plans to make Flow more interpopble with TS ecosystem? HOT 5
- Higher order type parameter support HOT 1
- Readme links to 404
- Strange index signature error if you use $Keys<O> instead of the equivalent literal union inside $ReadOnlyArray HOT 1
- [homebrew] automation script needs update HOT 2
- "Unxepcted identifier, expected the token ;" when using await inside of ES module HOT 3
- Can't iterate through chars in a string HOT 4
- Flow does not catch invalid switch statements HOT 1
- Conditional type only works if I inline it HOT 5
- Object with null prototype does not extend interface {} HOT 3
- Missing documentation for "render-types"? HOT 2
- Relay + graphql literals HOT 11
- [homebrew] regression test failure with 0.226.0,0.227.0 HOT 2
- FLOW BUG: This is a misplaced error HOT 3
- The `experimental.ts_syntax` doesnโt seem to do anything HOT 2
- Parameters<> does not support optional params HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from flow.