I am attempting to get a Node app with MongoLab working on Heroku. I get the following message in my Heroku logs: "Error: Cannot find module './shared'". I have uninstalled and reinstalled node_modules several times and have also installed a "shared" module, to no avail. The app runs fine on localhost. Is there anything I'm missing?
Just got the same issue. Seems you use latest node v6.0.0.
Please check you use the latest npm on Heroku.
Check the following in your package.json:
...
"engines": {
"node": "6.0.0",
"npm": "3.8.7"
},
...
Related
I have a typescript project which uses node:worker_threads. However, when I try to debug individual ts files, I keep getting error
Error: Cannot find module 'node:worker_threads'
It should be noted that the problem shouldn't be in the node version, I am running node 16.19.0 and have
"engines": {
"node": "16.x"
}
in my package.json. Any other idea what might have gone wrong? I am running Ubuntu 20.04 on WSL2, uninstalled node via apt and set it up by nvm. Thank you
It seems there was some weird conflict after all. In the end, the only solution that helped was to completely uninstall node, clean up leftover files and install it again.
So, I've used Parcel multiple times before and I've never had an issue with it.
This time it throws some stupid errors about SemVer versioning and I'm literally loosing my mind trying to find a solution which would fix this problem.
I've started new project: installed npm w/ npm init (no additional options), then installed parcel npm install --save-dev parcel-bundler and then created my folder structure:
--node_modules
--index.html
--index.js
Here is my package.json:
{
"name": "playground",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"dev": "parcel index.html"
},
"author": "",
"license": "ISC",
"devDependencies": {
"parcel-bundler": "^1.12.4"
}
}
I've configured default npm script to run parcel: "dev": "parcel index.html" and run it.
Everything works fine, however when I connect my index.js in index.html via <script src="/index.js"></script> it throws big fat error, saying:
D:\workingSpace\playground\index.js: Invalid Version: undefined
at new SemVer (D:\workingSpace\playground\node_modules\#babel\preset-env\node_modules\semver\semver.js:314:11)
at compare (D:\workingSpace\playground\node_modules\#babel\preset-env\node_modules\semver\semver.js:647:10)
at lt (D:\workingSpace\playground\node_modules\#babel\preset-env\node_modules\semver\semver.js:688:10)
at D:\workingSpace\playground\node_modules\#babel\preset-env\lib\index.js:276:22
at Object.default (D:\workingSpace\playground\node_modules\#babel\helper-plugin-utils\lib\index.js:22:12)
at getEnvPlugins (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\env.js:62:34)
at getEnvConfig (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\env.js:12:25)
at async getBabelConfig (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\config.js:32:19)
at async babelTransform (D:\workingSpace\playground\node_modules\parcel-bundler\src\transforms\babel\transform.js:6:16)
at async JSAsset.pretransform (D:\workingSpace\playground\node_modules\parcel-bundler\src\assets\JSAsset.js:83:5)
Currently I'm using Node v14.6.0 and accordingly it's npm version - 6.14.11
I've never faced this bug before, please help T_T
This is a known problem in the newest version of Parcel.
The solution of this problem was to revert back to version 1.12.3, or by updating to the version 2 of Parcel. You can do the first solution by:
npm uninstall parcel-bundler
npm i --save-dev parcel-bundler#1.12.3
The second solution could be done like this:
npm i --save-dev parcel#next
You might have to refactor your code a bit to prevent breaking changes if you decided to use the nightly version of Parcel. Check more about how to migrate to Parcel v2 / nightly here.
Catch up with that issue here.
Update #1: 28/05/2021
It seems that Parcel team has been working on a fix, as of the time of writing (28/05/2021). While I have not personally checked if the update has worked properly or not, this answer is still very much a viable and feasible solution.
I have recently went through this issue, where parcel#1.12.4 kept throwing Invalid Version: undefined even after trying a very logical workound posted on GitHub #5943.
Installing parcelV2 worked in my case. If anyone else is facing a similar problem, I would recommend trying the following steps:
npm uninstall -D parcel-bundler
npm install -D parcel#next
npx parcel serve index.html
I created a node.js application with runtime dependencies of scoped packages in my package.json:
"dependencies": {
"#shawnzhu/mybot" : "latest",
...
},
"engines": {
"npm": ">2.0.0",
"node": "0.10.38"
},
I also have a custom .npmrc that points scope #shawnzhu to my private npm registry.
Currently it works when deploying to heroku, where it upgrades npm to v2.7.x. However, a cf push to bluemix fails with the console output showing:
registry "#shawnzhu/mybot" not found.
After reviewing the whole console output I realized it uses npm v1.4.28 which doesn't support scoped packages.
How can I get npm v2.0.0+ in a node.js app in bluemix?
Before June 15, 2015: This was not possible using the default Node.js buildpack on Bluemix, yet. For now, you can use the community open-source Node.js buildpack:
cf push mynodeapp -b https://github.com/cloudfoundry/nodejs-buildpack
You've specified the npm version in your package.json correctly, so it should work for the community buildpack.
After June 15, 2015: The newest version of the IBM Node.js Buildpack is now available on Bluemix! You can see the full changes at https://developer.ibm.com/bluemix/2015/06/15/bluemix-node-js-buildpack-update/
This buildpack comes with the ability to specify NPM versions by including an "npm" entry in your package.json, like so:
"engines": {
"npm": "xxxxxxx"
},
I was also able to get this working using Node 0.12.2, with the following changes:
In package.json:
"engines": {
"npm": ">2.0.0",
"node": ">=0.12.0"
},
As of the latest Bluemix node.js default buildpack (c.Jun 4, 2015), you can specify a version of npm >2.0.0, which installs a version of npm >2.7, which is the requirement to support and import scoped npm packages. I have tested this for a publicly scoped package and it is up and running in production in Bluemix, using the default node.js buildpack.
If you don't want to revert and use the cf community buildpack, you can use the "engines.npm" property and that should get you up and running, even in node 0.10.x.
In package.json, specify:
"engines": {
"npm": ">2.0.0",
"node": "0.10.x"
}
I've edited this answer for clarity. Many thanks to #shawnzhu for comments. Hope this helps.
I am trying to add a Meteor.Js project to an OpenShift Gear by following this tut:
https://www.openshift.com/blogs/cloudy-with-a-chance-of-meteorjs
I had to use mongoDB-2.4 other than that I followed the rest of the tut.
upon pushing my project to the Gear and getting a success status from the rhc cli, I went to the URL and got a 503. Then I restarted the app, with the same results. Then I used the command:
rhc tail <appName> #<appName> is the actual name of my app
And got the error code:
Meteor requires Node v0.10.26 or later.
DEBUG: Program node meteorshim.js exited with code 1
DEBUG: Starting child process with 'node meteorshim.js'
After that I destroyed the gear and tried again this time changing the created package.json created by the meteor-shim to node version to '0.10.29' (it had originally said 0.10.9), I run 0.10.29 on my machine.
I bundled and pushed this one, with the same results. So I ssh'ed into the Gear and typed 'node -v' and it outputted
v0.6.20
How do I at least get node version 0.10.26?
Note: The Cartridge in the Application web interface says node.js 0.10
The answer is you can't get v0.10.26 or later on OpenShift currently. At least not that I know of. v0.10.25 seems to be the latest version you can get on OpenShift at the moment.
Although it shows v0.6.20 doing "node -v" while you're on their system, it's actually running v0.10.25 if you created your app as node v0.10. When you push your code on there, check the output, one of those lines should be:
remote: npm info using node#v0.10.25
I've tried changing the version in package.json as below to see if it works but v0.10.25 is the latest version OpenShift is currently providing:
"engines": {
"node": ">= 0.10.26", <<<<< it's not taking this version
"npm": ">= 1.0.0"
},
This is the error I encountered with package.json when running foreman start with Heroku Toolbelt for Node.js
"dependencies":
{
"express": "~4.4.0",
"jade": "~1.3.1"
}
I had the same issues as Jek. I was using express 4.4.4. I downgraded express 3.2.6 and it worked, but I shouldn't be forced to use an older version of express just because foreman doesn't support it.
I tried node-foreman. And it worked for me. I followed the instructions that included these steps:
npm install -g foreman
nf start
I would like to know if anyone has additional suggestions.
I managed to fix this issue by changing express version to 3.2.6 as seen below
"dependencies":
{
"express": "~3.2.6",
"jade": "~1.3.1"
}
Then I deleted node_modules and did a npm install. Following this a foreman start works perfectly fine.
However I have no idea why it doesn't work when it runs on express 4 but it works when running on express 3.