![]() ![]() Your start-app command is not easy anymore, which also sucks. If you're adding it only for the currently executing program, you're going to have to specify it each time you run your app. it's not very handy for development machines which need to run multiple applications. Setting application-specific settings as environment variables globally or in your current shell is an anti-pattern if you ask me. Does not touch other require calls to node_modules. That's a big plus compared to the other magical solutions around here. However it's very obvious for the next developer what's exactly happening. /./ for _base + which is only slightly better if you ask me. You're going to have OS differences one way or another. If you're using CVS or SVN (but not Git!), this solution is a great one which works, otherwise I don't recommend this to anyone. I would only advise this for the apps relying heavily on Object-oriented design principals and design patterns. If you're building a slightly bigger application, using a IoC Container is a great way to apply DI. You might need extra steps for this solution to work with linting and unit testing though. The also looks like something special is going on, which will tip off the next developer whats going on. Great solution, and a well maintained and popular package on npm. Linux, create app.sh in your project root:Ĭonst = require ( 'module' ) const requireUtil = createRequireFromPath ( './src/utils' ) requireUtil ( './some-tool' ) Conclusion app (also for Windows PowerShell)Īn advantage of this solution is that if you want to force your node app to always be started with v8 parameters like -harmony or -use_strict, you can easily add them in the start-up script as well. With one of these solutions (6.1 & 6.2) you can start your application like this from now on: The Start-up ScriptĮffectively, this solution also uses the environment (as in 5.2), it just abstracts it away. (On Windows this command will not work if you put a space in between the path and the &. Windows: cmd.exe /C "set NODE_PATH=.& node app" Start your application like this from now on: It does change your application start command. This solution will not affect your environment other than what node preceives. To have it globally available in any shell, set it in your userprofile and reload your environment. ![]() Setting a variable like this with export or set will remain in your environment as long as your current shell is open. This shell, so you must open a new window).Const Article = require ( 'app/models/article' ) 5.1. This in a shell with administrator permissions.
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |