I'd like to have my project using the following structure :
|_ bin
|_ docs
|_ logs
|_ src
|_main
|_ api
|_ config
|_ views
...
app.js
|_test
|_ node_modules
|_ package.json
By default, the app.js is in the same directory as the npm modules, is it possible to do it my way? I modified the .sailsrc file to change the paths (especially for the adapters), but once I try to run the app, the sails module can't be found.
I'd like to have my project using the following structure
is it possible to do it my way?
No.
The solution is to to build your sails.js app the same way as the thousands of other sails.js applications. If you don't want to follow convention, you're on your own.
Related
I'm new in node world and I'm in facing with a problem,
Currently I'd made a split in the project (in ts) where I work in two new packages(using ts also), to be shared between applications.
All this code are in the same repo, popularly called "monorepo". Below I'll illustrate how this are joined.
But even using the npm link when we made the transpile, from this ts to js these code wasn't included in the final build, to solve this I created two npm packages.
Therefore, apparently this have been adding more complexity into development, because when we need change something in these packages, we need do a link between these package and the project and then if we made some new modification in the packages, it's needed run the npm build in these packages to update the source to be used, because I import the package transpiled (I have some issues regarding the es6 and your imports, node don't accepted it).
I would like how can I improve this method to be less bureaucratic and more effective.
To illustrate my current situation:
/Repo
|_ _/my-app
| |_ _/node_modules
| | |_ _/package-A (npm package)
| | |_ _/package-B (npm package)
|_ _/package-A
|_ _/package-B
|_ _/others-apps
I have recently packaged an electron app using electron-builder:
myProject/
├── package.json
├── app/
└── release/
All files created by electron-builder are place in the release directory. The executable works fine on my local machine, with all features present through the packaged app.
However, once I move the application to another machine only some features are available. Noticeably features within subdirectories in app/ are not included.
For example here a snippet of the app/ directory:
app/
├── app.html
├── index.js
├── components/
└── other files and folders
Features added from .js/.html files within components/ are not present when I move the app to another machine. I have tried both moving just the executable as well as the whole release/ directory, neither includes additional features beyond what is included in app.html.
Update
It does indeed look like any other machine simply doesn't read items contained in
<script></script>
In my app.html file
Would there be some outside installation I need to do on another machine to get this executable running
Found the issue,
It involved my usage of a two package.json structure
Both dependencies and devDependencies of my build were located in the root/package.json, where dependencies needed to be moved to the app/package.json file
I am developing an AWS SAM application in nodejs and have two lambda functions (each are distinct node modules) which both share a third node module which is shared utility functions.
I am using the install-local npm module to install the shared local utilities node module into the lambda function node modules post-npm-install because SAM local-start doesn't appear to work with symlinked local modules.
This works fine when I start the SAM API locally and hit the end point and I can successfully debug the Lambda functions, however, when I step from the Lambda function code into a function within the shared utilities node module, it opens the file from the lambda function's node_modules directory (local-install doesn't symlink from node_modules to the shared code on my local file system).
I would very much like to somehow map the file in the lambda function's node_modules to the shared utility code on my local file system.
Here is my directory structure:
root
|
|- LambdaFunction1
|- app.js
|- node_modules
|- SharedUtilityFunctions
|- app.js
|- node_modules
|- LambdaFunction2
|- app.js
|- node_modules
|- SharedUtilityFunctions
|- app.js
|- node_modules
|- SharedUtilityFunctions
|- app.js
|- node_modules
In this example, I want to (only when debugging in VSCode) map root/LambdaFunction1/node_modules/SharedUtilityFunctions to root/SharedUtilityFunctions
Does anyone know how this can be achieved?
Maybe I am totally off track here and I am chasing the wrong Idea:
I have node.js project which contains an npm module (let's call it my_npm_module) which I am also working on.
The module's directory is symlinked into my project like this:
/home
|
|__ myproject
| |
| |__ node_modules
| |__ some_other_module
| |__ my_npm_module (should only get installed/updated in production mode)
| |__ my_npm_module (symlinked only in development mode from /home/modules/mymodule)
|
|__modules
|__ my_npm_module (symlinked to /home/myproject/node_modules/mymodule)
Now, when I call npm install/update in development mode I don't want mymodule to get installed/updated, since I want to use the symlinked version.
But I want mymodule to get installed/updated in production mode. And only in production (NODE_ENV=production) mode.
Since package.json "dependencies" installs/updates for either mode i.e. development and production and "devDependencies" installs/updates for development mode only, I am kind of stuck here.
What I am looking for is something like "productionDependencies" or at least a solution which covers this situation.
Sorry, there is no way to do that.
What you could do is add an extra line when you deploy.
$ npm install my_module
$ NODE_ENV=production npm install
And when you finish with your module development ( let's say you don't want to link it anymore, because it's ready for production ), you just remove that extra line and add it to your dependencies.
Another idea is to modify your package.json file for production in your deploy script. This will ensure that the module will be installed only for production.
When pointing to a different location of a package my app needs, I can usually just replace the version with "depName": "githubUser/repoName" and it works great.
But what should I do if the package I need to customize is itself a node module of some other package? e.g.
myapp
|_
express.js
|_
send.js
I prefer to avoid publishing a fork of the first package, express in this example, just to use a modified version of send.