I am trying to integrate 2 react apps I have been working on into 1 new react application (all created using npx create-react-app nameofapp) but I can not get the libraries I have used in the previous app to load/work in the new application even though I have copied the depencencies from the previous application and pasted in the new package.json file and run npm i and can see the folders for the libraries in node_modules folder of new application.
I am only importing fs in the js file from previous application at the moment and still get an error when running npm start which is module not found and it seems to be looking in the src file probably because the js file is in the src folder which is using import fs from "fs" to work with the fs package.
One other thing I can see different is that I had to run node app on previous application in src folder to start it where npm start runs this application.
I'd really appreciate help with this as I am still new to node and have been stuck all day on just integrating 2 applications into one.
Related
I am quite new to programming and today decided to attempt and create a node.js and puppeteer project with the purpose of scraping website into a .txt file. I ran into issues straight away since for the most part I have no idea what I'm doing. After installing node.js and puppeteer, I was guided by some videos and articles I found to create my first project. In the command prompt using mkdir and later cd I was able to create and access the new directory, but I started running into problems with npm init. It only places the file package.json in the repository, but there isn't a package-lock or node_modules file anywhere. No idea what they do but thought this was a problem. When I open cmd and try to run the app by typing node app.js it returns Error: Cannot find module 'C:\Users\emili\app.js' along with some other gobble. What should I do, to be able to run the simple application I wrote?
It seems that you are missing some key knowledge on how NodeJS works, but in order to fix your issue (for now), you will need to take a few steps.
First, in your working directory (where the package.json is), you'll need to install your modules.
Run npm install puppeteer. This will do two things, create the node_modules folder and create the package-lock.json file.
Create a file named app.js (either manually or by running the command touch app.js) in your working directory, and put the following content inside of it:
console.log('Hello, World!');
Save the changes to app.js and then run node app.js in your terminal. You should see Hello, World! output to the terminal.
The reason npm install puppeteer created the node_modules folder and the package-lock.json file is because they weren't needed beforehand.
When you run npm install PACKAGE_NAME, you're installing a module (otherwise known as a package), thus it creates the node_modules folder so that it will have a place to put the module so that your code can access it. It also creates the package-lock.json file, which is used to track the module versions inside of your project.
With this information, I request you go back to the tutorial you were originally following and try going through it again and attempting to understand each of the core concepts before writing any real code.
showing Failed to find package.json. Node.js may have issues starting. Verify package.json is valid or place code in a file named server.js or app.js. when deploying node js file in AWS ELASTIC BEANSTALK cloud, what are the reasons to showing that message and how to resolve that issue.
There can be multiple reasons. Can you please check the logs generated in Beanstalk.
The way how you have zipped the package can cause an error. Make sure, you go inside the source directory and zip the files and folders, instead of zipping the single folder itself.
Secondly, the way how you have created the app.js or index.js.
The Nodejs versions can be another reason.
The below approach worked for me 2 years back when I started using Beanstalk for my Nodejs applications.
Also, I would recommend deploying a sample nodejs application from this link and progressing from there. https://docs.aws.amazon.com/elasticbeanstalk/latest/dg/nodejs-getstarted.html
I have a problem with an app based on electron. When I build my electron app with electron-builder it produces a appname.exe file which has probably the html/js/css sources in the exe file or another one in the produced directory. When I try to require a node_module from the developer console in the builded app, the module is not getting found :(.
The app is looking in a file called electron.asar liked it seems for the module. I don't really understand this because over modules are getting found, otherwise, the app would not be able to start anyhow.
Maybe one of you guy's have already faced that problem?
yes, the module needs to be listed in the dependencies section in the package.json to be found in the built electron app.
I am learning building Node modules and packaging it with Electron. I've successfully built an module out of a CPP file and can run it with node. However, to run it with Electron I need to rebuild Electron. There are instructions out there, for example:
https://github.com/electron/electron/blob/v0.37.2/docs/tutorial/using-native-node-modules.md#using-native-node-modules
https://github.com/electron/electron/issues/2330
Here I have an addon.node file after running node-gyp build. I can reference it in the node application from anywhere: var addon = require('.Release\addon'); and it works fine. However, when I build Electron with it I don't understand where to put the .node file so that it is used in the build. Before I run node_modules\.bin\electron-rebuild (see bullet point 1 link above) where should I put the addon.node file? Is it right to say that before I even test it withing Electron (with console.log or something) I need to run electron-rebuild. Is there a step that I missing that I need to take from having the addon.node file to starting to build it into Electron?
Thank you.
I am a beginner to mean.
I have followed the following steps to create meanjs app :
installed node v0.12.7
npm install -g bower
npm install -g grunt-cli
npm install -g yo
npm install -g generator-meanjs
cd C:\Users\SHIVAM\Desktop\MyApp
yo meanjs
MyApp folder containing mean directory created
Error occured on yo meanjs 1
Please provide a solution . I am struck at the first phase. I need to get started as sson as possible .
Version 0.4.* has different folder structure. The tutorial you are following is probably using earlier version of meanjs. You can find the new structure here-http://www.bossable.com/954/version-0-4-0/ She has compared the structure with the older one. I was going through the same problem. Follow these tutorials, it will be of great help.
The following directories have been changed in the 0.4.* versions of Meanjs; 0.4.2 is still unstable. 0.4.0 and 0.4.1 is recommended for beginners to get on MEAN.
-New files have been added
1) gulpfile.js-Gulp is relatively faster than grunt because gulp focuses on code rather than cofiguration. It uses node.js’ streams, and executes faster, since it does not open/close files, or create intermediary copies all the time. The lack of any up-front configuration, especially, specifying a source and destination is noticed immediately in this file.
2) protractor.conf.js-Support file for end-to-end testing in angularjs applications. (Pretty Neat.)
The app folder is removed, which is the major concern for the noobs trying their hands on MEANjs following the older tutorials. Controllers,views, models are now moved into a separate folder called modules which was previously in the public folder.
You can explore modules/core/server and modules/user/server of your project
Addition of client, server and test in modules/core and modules/user folder. All the client side angular will now be in the modules/core/client making it easier to access all services and directives of different modules of the application at one place. And all the backend or server-side files goes to modules/core/server.
public/application.js and public/config.js are now config.js and init.js in modules/core/client/app folder.
config folder is split and new folders assets and lib are added.
The previous env folder have been split into env and assets. All the references, mongodb port, session keys goes to the environment(env) whereas new libraries we are defining into our project goes to assets. For instance new css, sass or less reference will be defined into asset/default.js. config.js and init.js are merged into one file config/config.js.
lib contains express.js, mongoose.js and socket.io.js.
node_modules is pretty much exactly the same as the previous versions of meanjs.
These are the major changes in the folder structure. New models and controllers are added into the modules/users/server according to your application, just so you don't get lost while developing your project.