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
Related
I have a node app built with an unknown node and npm version. Is there any way to guess the version, or at least a version range, from package-lock.json?
I do have "lockfileVersion": 1,, which means npm v5 or v6. Any way I can get more granularity?
The reason I need it is, I am getting a bunch of errors like these when running ts-node, unless I delete and rebuild package-lock.json. Which I'd rather not do, for various reasons.
ts.Debug.assert(typeof typeReferenceDirectiveName === "string", "Non-string value passed to `ts.resolveTypeReferenceDirective`, likely by a wrapping package working with an outdated `resolveTypeReferenceDirectives` signature. This is probably not a problem in TS itself.");
Simply search for "#types/node" inside package.json. It will give you node version used. Now search the relative npm version installed for the node version.
"#types/node": {
"version": "16.9.4",
"resolved": "https://registry.npmjs.org/#types/node/-/node-16.9.4.tgz",
"integrity": "sha512-KDazLNYAGIuJugdbULwFZULF9qQ13yNWEBFnfVpql......",
"dev": true
},
When I use nodegit in electron, I got the error when I start the app:
App threw an error during load
Error: A dynamic link library (DLL) initialization routine failed.
\?\D:\Electron\hello\node_modules\nodegit\build\Release\nodegit.node
at process.module.(anonymous function) [as dlopen] (ELECTRON_ASAR.js:166:20)
at Object.Module._extensions..node (internal/modules/cjs/loader.js:740:18)
...
I can use nodegit in nodejs successfully, but failed in electron.
Even I added .npmrc file with content below, it's still faield.
runtime = electron
target = 1.2.8
target_arch = x64
disturl = https://atom.io/download/atom-shell
Does anyyone know how to fix it in electron?
My environment is windows 10 x64 with vs 2017, node 10.13, electron 3.010
I had the same problem with another node package using electron 3.0.6 and eventually got it working.
Try these:
Make sure the packages are listed under the dependencies and not devDependencies in the package.json
Add this "electron-rebuild --force node-gyp rebuild --target=3.0.6 --arch=x64" to postinstall under the scripts section. I ended up with this in my packages.json (my DLL error was for "printer")
{
"name": "myproject",
"version": "1.0.0",
"main": "main.js",
"scripts": {
"postinstall": "electron-rebuild --force node-gyp rebuild --target=3.0.6 --arch=x64",
"start": "electron ."
},
"dependencies": {
"#types/node": "^10.12.18",
"electron-rebuild": "1.8.2",
"electron": "3.0.6",
"printer": "0.2.2"
},
"devDependencies": {
...
}
}
See here for more info
Hope this helps someone
From this link:
The most common issue though is that the component was not properly installed, so that some of its dependencies are not available.
First confirm if global node version matches with the project one. Some projects require specific version hence first delete other node and install required node version and project dependencies. Try below solutions to solve the errors as same worked for me
Clean up node modules [ https://medium.com/#mariokandut/how-to-clean-up-node-modules-5aed676156db ] and rebuild the project. It rebuilds node_modules folder
Since it is an electron app try yarn electron-rebuild. For more info on yarn refer " https://www.digitalocean.com/community/tutorials/how-to-install-and-use-the-yarn-package-manager-for-node-js "
If electron rebuild fails check if "Visual C++ Build Environment" are installed. Refer https://stackoverflow.com/a/61252536/9558119 for same.
Rerun electron rebuild and then run build as per your project
I am pretty new to this environment still and am trying to get up to speed on node.js modules and Laravel (5.1.11) as a whole, so...
I have a fresh install of Laravel implemented by the cPanel Installitron. I'm using PHPStorm to install all of the node modules via the provided package.json:
package.json
{
"private": true,
"devDependencies": {
"gulp": "^3.8.8"
},
"dependencies": {
"laravel-elixir": "^3.0.0",
"bootstrap-sass": "^3.0.0"
}
}
The error I get when I run the install is:
Cannot download "https://github.com/sass/node-sass/releases/download/v3.13.1/win32-x64-57_binding.node":
HTTP error 404 Not Found
I can understand why this would happen, seeing as that is an older version of node-sass, but how do I know what newer versions are compatible with the requested version of laravel-elixir? I didn't want to just install a newer version of node-sass because digging a deeper hole would make it harder for me to find a solution to my problem. What is the fix for this?
It looks like you can fix this by installing Windows Build Tools via this command:
npm install --global --production windows-build-tools
Then delete the project's node_modules folder and re-run npm install.
Just follow this official url well doc.: https://laravel.com/docs/5.3/elixir if you get any error. I just comment and i ll be here.
At times, npm install prints following line in the output
"Using Node version X.Y"
What does that mean?
Does npm install itself spawns a node process to perform dependency installation? Or is it just echoing node version to inform the user that all dependencies are expected to work with this node version?
It's echoing the node version used in npm's package.json
{
"name": "sample-app",
"version": "0.0.1",
"engines": {
"node": "6.1.0" <-- this
}
}
Like Medet answered, it retrieve node version from your package.json file. After that it shows all the modules it installs, and in the end (in case everything went well) it shows all modules and their deps in a tree like structure.
You haven't asked this but I don't think it'll hurt if I explain how it installs modules because your question is quite broad and in your description you just asked about the version of node.
First of all, it nests dependencies and then install all modules from NpmJs using queue (reason for long installation time)
Next, it creates a node_modules and all the packages go inside that directory.
If you are understanding the concepts of NPM then I will suggest you refer to this blog
It has been pretty frustrating finding the solution to this problem today, as I've tried searching on Google and went to all of different forums and websites in search of a solution, but none of them worked for me.
Is there anyone who could tell me what I could try in order to solve this?
Facts:
Fresh Laravel installation
Ran npm install
Ran npm install gulp
Ran gulp
Got this error
package.json contents
{
"private": true,
"devDependencies": {
"gulp": "^3.8.8"
},
"dependencies": {
"laravel-elixir": "^4.0.0",
"bootstrap-sass": "^3.0.0"
}
}
try to remove the node_modules directory completely and issue npm install or npm install --no-bin-links without gulp, gulp should already included in packages.json
Very old question I know, but, if still having issue...
Try to run
npm install laravel-elixir --save-dev
command manually on prompt.
And then make sure you added following code line in gulpfile.js file
var elixir = require('laravel-elixir');