NPM on LEMP cannot find module, wrong path - npm

Total Linux noob here. I am trying to configure a Pleroma development environment on DO droplet. Installed LEMP, installed SSL, installed PostgreSQL, installed Pleroma, so far so good.
Then I installed Node, NPM, cloned Pleroma-FE (apparently it installs in /user/pleroma-fe folder). I am following the very brief build instructions here:
https://git.pleroma.social/pleroma/pleroma-fe
When I get to the command in those build instructions: npm run build
I am getting error: Error: Cannot find module '/user/build/build.js'
It's because actual path to the build file is /user/pleroma-fe/build/build.js
Apologies if this is a duplicate. I see other questions about this.
Fixing npm path in Windows 8 and 10
and the reply seems to set the PATH. This answer might apply to my situation. But my question is: it is clearly already looking in a well defined path (which is different from all the other questions, which don't seem to have well defined path in the error message). But it is the wrong path. How do I make it look in the correct path?
I tried the npm command and specified the complete path, and every variation. and none worked. So it seems fixing the path won't fix this problem.
Sorry I do not currently know enough Linux to be able to fix this. I tried to tag this with Pleroma but I don't have enough reputation to create a new tag. Any help is much appreciated. Thanks in advance.

I continued to work on this with some help of a Linux admin on Fiverr and the Pleroma developers chat with success, thanks to all.
The solution did not involve changing the path. There were several different things going on. First, I needed to change directory into the development project source folder:
cd pleroma-fe
Once I did that, npm found the build module. Next issue was Node was very old and I needed to get the latest version. I used the instruction here for NodeJS (10):
https://nodejs.org/en/download/package-manager/#debian-and-ubuntu-based-linux-distributions
Next issue was npm was missing some modules. This was fixed with:
npm install
After that the build completed with no errors.
npm run build
After a successful build, you will see a list of files that have changed as a result of the build.
Next issue is that simple changes in HTML text were not live, ie. not reflected in the refreshed web page. This is fixed by copying all the resulting build files to the production folder using rsync. In my case the command was:
rsync -av /user/pleroma-fe/dist/ /home/pleroma/pleroma/priv/static/
Pleroma is a neat Twitter-like user interface to ActivityPub fediverse, it includes a Mastodon UI as well, and thanks to the developers for making it free and open source.

Related

EAS building fails with package.json error

Using Managed workflow
Your eas-cli version
eas-cli/2.7.0
win32-x64
node-v16.10.0
What you have tried so far
Clicked through every link on Google I could find (none mentioned this error specifically)
Read the Expo Documentation as well as Troubleshooting Guide
Ensured that the package.json is in the root directory
Error: package.json does not exist in /Users/expo/workingdir/build
I am building for iOS and having no issues up to the ‘Prepare Project’ phase. Each subsequent fails with the same error.
I have no idea where the ‘/Users/expo/workingdir/build’ directory actually is, as I don’t have an ‘expo’ user on my machine. Do I need to create these directories?
I don't post here so let me know if I need to add anything else.

Sanity not starting anymore, even though I'm in the right file

I'm making sure to type in sanity start in the right file pathway (for me its the Website folder). Its been working for me fine the past week and up till today, but not anymore. I'm worried I've messed with my Sanity files somehow, its my first time trying to use a backend so its possible I've done something I shouldn't have (I was having confusions around sanity client last night, and that my current sanity version didn't support my current react version). I think I remember trying to upgrade sanity through the terminal, but otherwise I don't remember making any other changes. I'm currently having a big issue trying to fetch data from the backend, so that's been a whole thing too.
This is the whole message I'm getting in the command prompt:
#sanity/core not installed in current project
Project-specific commands not available until you run `sanity install`
Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "#sanity/core"
is installed as a dependency.
at _.runCommand (C:/Users/kiras/AppData/Roaming/npm/node_modules/#sanity/cli/bin/sanity-cli.js:3608:1340)
at t.exports (C:/Users/kiras/AppData/Roaming/npm/node_modules/#sanity/cli/bin/sanity-cli.js:1980:2422)
This is my first comment so I apologize if I'm not following some standard that StackOverFlow-culture has.
I got the same error as you, as shown below.
Error: Command "start" is not available outside of a Sanity project context.
Run the command again within a Sanity project directory, where "sanity"
is installed as a dependency.
at CommandRunner.runCommand (~/.nvm/versions/node/v18.12.1/lib/node_modules/#sanity/cli/lib/_chunks/cli-3984b311.js:17742:33333)
at Object.runCli (~/.nvm/versions/node/v18.12.1/lib/node_modules/#sanity/cli/lib/_chunks/cli-3984b311.js:17745:2460)
Yesterday everything was fine but today, Sanity was not working. I was in the right file and directory, and my JSON package was formatted properly as well. I tried installing and deleting many things but nothing worked. I ran this command in the studio directory:
sanity install
After that prompt, I got the following:
The `#sanity/core` module is not installed in current project
Project-specific commands not available until you run `npm install`
? Package manager to use for installing dependencies? npm
Then... I got a ton of "npm WARN deprecated" warnings but then I tried:
sanity start
and it worked? I hope this helps, goodluck!
If this doesn't work, make sure you have the following:
Scripts are Correct in studio/package.JSON
"scripts": {
"start": "sanity start",
"build": "sanity build"
},
If you accidentally deleted some JSON file, you can use:
npm i
to get it back, I made that mistake but make sure you're in the proper directory (web or studio).
Apologies for the long response, but this should work, a lot of the responces gave the same repetitive answer ("cd into sanity folder by writing cd sanity and then sanity start") and it frustrated me seeing the same thing 715,143,763 times lol
Good luck!

React Native Xcode 13.2 Error no such file or directory for NativeVibration.js

After creating the project with react-native init, i found this issue in terminal as well as in xcode. After digging deep, i found that this particular file is showing missing in project node modules.
Here are example of error codes showing in xcode & terminal-
Error: ENOENT: no such file or directory,
/ios/Pods/../../node_modules/react-native/React/FBReactNativeSpec/../../Libraries/Vibration/NativeVibration.js
I've learned the hard way when programming in react native (for cross platform/hybrid application development), many unknown issues will be caused if you deviate from native OS clustering. Make sure you don't make the same mistakes as I have.
I have more specific help for you, apart from the obi wan style in my previously semi-answer.
Another guy had an issue with this a few years back, he asked and was answered,"delete your node_modules and app from simulator. Then re-install everything back, clear cache and see if it start bundler from root directory.
Before doing that, you can try 'react-native start' from your root directory.
I have seen that error message a lot, specifically with jest. But that's a different fix. I realize you are not using jest to test your reactjs, but it is jest tests runner that is the problem that causes the same outcome as you have come to- solution there is to disable the jest runner from running in the background while installing new packages.
I wonder if there isn't a similar solution here - only applicable to xcode - although you see it in terminal, that's probably just the cmdline not recognizing the path to the directory or at least that file.
Should be easy to figure out with terminal--
Go to $HOME~ type dir or ls, to see your directory folders, if you see the project listed, cd into it or, just search for the directory apt-get search [package] or apt, pkg, pip, pacman, snap etc etc whatever your flavor if OS terminal is, or search for the file-- $find / -iname [query] or even search for all paths containing the phrase: $locate [query]... If you created it, it exists. Just because xcode can't find it, and initial attempts in term produced nada, don't believe it is not in your system. just a matter of where, what, and why a process or dependancy is missing or malfunctioning in attempt to retrieve the file & open it.
You can definitely find it - i don't know jack about xcode, but terminal -- I can get anything from anywhere on cmdline-- you can too. I have to go, but I'm curious if you have figured it out. Let us know yeah? Best of luck to you. Cheers QwaziRidwanhasib.
-Cujo

zsh: command not found tickets (macOS)

first of all, I'm not really good into this, but I installed something with npm.
npm i tickets
npm install -g tickets
Installation was succesfull and it worked fine. Afterwards, I wanted to look into the sourcecode to find sth. I needed to edit. I open the folder "tickets" into visual studio code and searched through the sourcecode but couldn't find it. Then I wanted to start it again and then it started - getting this error:
zsh: command not found: tickets
When I was working in visual studio code I was in the "tickets" directory. So, like in the beginning when It worked, I switched to home directory but I still keep getting the error. I have no idea why it doesn't work not. Basically, I did nothing except being in a different directory.
I tried to fix it with exporting the path (using a MacBook):
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin:/usr/sbin:/sbin:$HOME/npm/bin
But did not work out.
I'm struggling now by testing out different solutions I found. Hope someone can help me out in a noob-friendly way! Thanks!
npm i installs a package in the current project. If you want it to be available from anywhere, you need to install it globally - npm install -g tickets (you'll probably need sudo in order to do that, though).

Peer dependency that is also dev dependency of linked npm module is acting as a separate instance

In my app, I have these dependencies:
TypeORM
typeorm-linq-repository AS A LOCAL INSTALL ("typeorm-linq-repository": "file:../../../IRCraziestTaxi/typeorm-linq-repository"), who has a dev dependency AND a peer dependency of TypeORM
The reason I use a "file:" installation of typeorm-linq-repository is that I am the developer and test changes in this app prior to pushing releases to npm.
I was previously using node ~6.10 (npm ~4), so when I used the "file:" installation, it just copied the published files over, which is what I want.
However, after upgrading to node 8.11.3 (npm 5.6.0), it now links the folder rather than copying the published files.
Note, if it matters, that my environment is Windows.
The problem is this: since both my app and the linked typeorm-linq-repository have TypeORM in their own node_modules folders, TypeORM is being treated as a separate "instance" of the module in each app.
Therefore, after creating a connection in the main app, when the code that accesses the connection in typeorm-linq-repository is reached, it throws an error of Connection "default" was not found..
I have searched tirelessly for a solution to this. I have tried --preserve-symlinks, but that does not work.
The only way for me to make this work right now is to manually create the folder in my app's node_modules and copy applicable files over, which is a huge pain.
How can I either tell npm to NOT symlink the "file:" installation or get it to use the same instance of the TypeORM module?
I made it work pretty easily, although I feel like it's kind of a band-aid. I will post the answer here to help anybody else who may be having this issue, but if anybody has a more proper solution, feel free to answer and I will accept.
The trick was to link my app's installation of TypeORM to the TypeORM folder in my other linked dependency's node_modules folder.
...,
"typeorm": "file:../../../IRCraziestTaxi/typeorm-linq-repository/node_modules/typeorm",
"typeorm-linq-repository": "file:../../../IRCraziestTaxi/typeorm-linq-repository",
...