I made a test project, only trying to include https. I used expo init test to initialize the project, then npm install https to install the library.
I then edited App.js and included this line at the very top: import {https} from 'https';
Finally expo start to start the expo server.
Now I get the following error:
InternalError Metro has encountered an error: While trying to resolve module `https` from file `/path/test/App.js`, the package `/path/test/node_modules/https/package.json` was successfully found. However, this package itself specifies a `main` module field that could not be resolved (`/path/test/node_modules/https/index.js`. Indeed, none of these files exist:
* /path/test/node_modules/https/index.js(.native|.android.expo.ts|.native.expo.ts|.expo.ts|.android.expo.tsx|.native.expo.tsx|.expo.tsx|.android.expo.js|.native.expo.js|.expo.js|.android.expo.jsx|.native.expo.jsx|.expo.jsx|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.wasm|.native.wasm|.wasm)
* /path/test/node_modules/https/index.js/index(.native|.android.expo.ts|.native.expo.ts|.expo.ts|.android.expo.tsx|.native.expo.tsx|.expo.tsx|.android.expo.js|.native.expo.js|.expo.js|.android.expo.jsx|.native.expo.jsx|.expo.jsx|.android.ts|.native.ts|.ts|.android.tsx|.native.tsx|.tsx|.android.js|.native.js|.js|.android.jsx|.native.jsx|.jsx|.android.json|.native.json|.json|.android.wasm|.native.wasm|.wasm)
I've verified that these files do indeed not exist, here is the output of ls node_modules/https: package.json
So I'm guessing I did something wrong during the install process, however, I can't figure out what. (I've also tried several times to install using yarn add https, I got the same error)
The https module you want is almost certainly the Node.js built-in https module and is definitely not the six-year-old https npm module with no documentation or code and merely a lone package.json file. That package should probably be deprecated so people don't make this entirely understandable mistake.
In short, try npm uninstall https and see if your code starts working. It probably will.
If not and you really need some external module, it's definitely not that module. Look at one of the many many great http/https modules out there. #Nitish suggests axios in their answer and that is a popular and solid choice.
import {Agent} from 'https'; should work with the built-in https module assuming you're working with a reasonably recent version of Node.js. (You can quickly test your version of Node.js for this by putting that line of code in an index.mjs file and running node index.mjs. If there's no error message, it worked.)
Disclaimer: I know nothing about expo. This is all from a Node.js/npm perspective.
the error is clear that your package.json don't have https module.
I don't know why you need this module but if you need this for REST API I suggest fetch or if third party you can use axios.
Related
After installing node-pty (an external module used to create pseudo terminals using node js) in a boilerplate electron-forge project; I found it throwing an error that some core module of node-pty is importing another module which nodejs is failing to find.
After some research I discovered that entry point of node-pty is src/index.js, which imports another module called src/unixTerminal.js (this file is imported if the system is running on linux platform and my PC is running on Ubuntu 20.04) and that module tries to import build/Releases/pty.node.js (unixTerminal.js calls many functions imported from pty.node.js, so this package cannot be ommitted) but as a matter of fact build/Releases/pty.node.js is missing and completely absent in the node_modules/node-pty folder of my project where I had installed node-pty
Why does this happen? Is this any fault of myself in installing node-pty, I had installed it directly using npm i command? If a vital file of a module is missing how can it work? Please tell me how can I use node-pty on Linux and why build/Releases/pty.node.js is missing in node-pty's directory?
Since you're using Electron Forge (a crucial detail omitted from the original post), according to this issue I found by googling "node-pty electron forge" you'll need to configure the Electron packager to unpack the pty.node file:
asar: {
unpack: '**/node_modules/node-pty/build/Release/*'
},
I'm new to node.js, and I can't seem to run my node app.js file after adding in a new file called projects.js with only this JS code:
exports.viewProject = function(req, res){
res.render("project");
};
This is a pre-coded project from my (useless) professor, and I'm getting this error:
I have Big Sur, uninstalled and reinstalled node, tried sudo, and it still doesn't work. Here is my app.js code as well, and I only added var project and app.get('/project'... etc).
Sorry if this is lengthy, I'm just trying to make it through online classes during a pandemic. Thanks!
The warning that Express is giving you tells you that you're trying to use built-in middleware that aren't included in Express anymore. Some of them have been deprecated over 9 years ago when Express 2.x was deprecated. The current version as of writing is 4, and version 5 is in alpha.
Some of these have not been bundled with Express since 2012 (2.x), some of them since 2015 (3.x):
express.favicon() - handled by express.static() as long as your favicon.ico is inside the public directory
express.logger() - use the morgan package instead
express.methodOverride() - use the method-override package instead, although you probably don't need this
express.cookieParser() - use the cookie-parser package instead
express.session() - probably became express.cookieSession() in 3.x, removed after 3.x, use the express-session package or alternatively cookie-session
As Sebastián mentioned in the comments, app.use(app.router) is also redundant.
Additionally, the express3-handlebars package is also deprecated as it's for Express 3 (like the name suggests). If you go to its NPM page, you'll see a big banner telling you to use express-handlebars instead.
Your package.json file also includes a package named node which, according to its description, can be used to run scripts from dependencies with a specific node version. You also most likely don't need this at all, and can uninstall with npm.
As a closing statement, if the base for this project was provided to you by your educational facility, I would suggest giving them feedback and telling them that it would be time to update the examples.
I've been trying to use a npm module called solc in AngularJs but I can't seem to succeed in anyway.
I know it's meant to be used with a Node application but I was wondering if there is a way to use it client side.
I've been trying to use Require.js and require every file included inside the git-repo but there are too many dependencies so I was wondering if there is another way.
I've been looking at browserify but that doesn't seems to do exactly what I need.
Does anyone have any idea?
You can use a npm package in browser applications if the package does not have any dependency on Node's built-in APIs. That's because Node APIs are available on server side and not on browser.
If you see here and here in the github repo of solc, you will see that it requires Node's built-in modules path and https. So it will not work in any browser application.
I'm sorry if this doesn't count as a "Programming Question" but I found it relevant since this will make me able to do programming in the Podio API.
My question/problem is that I can't figure out the correct way to set up the Podio JavaScript SDK/API scripts. I followed "http://podio.github.io/podio-js/" but it really only explains so much.. Mostly about Node and that I need to use Node for it, but isn't there another way like simple Ajax calls?
Reason being, I don't have the possibility of running a Node server in my server background, just to make API calls, it may be effective but it sounds kind of stupid when so many other API's out there doesn't require this.
Thoughts?
podio-js is a Podio JavaScript SDK for node and the browser.
... which means you don't necessary need Node.js. To use NPM module in the browser you'll need a bundler, like Webpack:
npm install podio-js --save
npm install webpack --save-dev
Then in your app.js:
var podio = require('podio-js');
// follow the tutorial
To bundle the app:
./node_modules/.bin/webpack app.js app.bundle.js
Then include the bundle in your HTML via script tag and voilà:
<script src="app.bundle.js"></script>
I have installed Meteorite on my mac, and am trying to run the test program provided as a mysql project. When I use the command 'mrt', I get:
Stand back while Meteorite does its thing
Done installing smart packages
Ok, everything's ready. Here comes Meteor!
[[[[[ /Users/lfrey/Desktop/Thesis/test-meteor-sql ]]]]]
=> Errors prevented startup:
While building the application:
node_modules/meteor/app/lib/unsupported.html:1: Can't set DOCTYPE here. (Meteor sets for you)
node_modules/meteor/app/meteor/meteor.js:1:15: Unexpected token ILLEGAL
=> Your application has errors. Waiting for file change.
I have tried re-installing nom, meteor, meteorite, and mysql in various combinations and have not been able to eliminate the error. If I remove the command, then I get an error about invalid HTML syntax.
Your app might not be created properly. You have a node_modules directory in your application which you might have added with npm install.
Meteor does not install modules with npm install manually, it doesn't work because it parses files in the node_moules directory as part of your meteor app (in the wrong way - not as an npm module).
You have to make sure the package you use uses Npm.depends in your package's package.js. The standard Meteor-SQL package already does this for you so you don't have to worry about it.
Which SQL package did you use? As far as I can see none of them install anything with npm install nor do they have instructions to.
The simple fix to get your app working is to remove the modules you installed by deleting the node_modules directory in your app.