Open Legends opened 4 years ago
In order to make it work on windows 10:
create and execute the following index.js
file:
const run = require("@webpack-contrib/defaults/dist");
run();
or add the command by hand to scripts after installation:
scripts:{
"default" : "webpack-defaults"
}
Errors experienced on windows during command execution:
1.)
del-cli dist
'del-cli' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1
2.)
babel: src does not exist npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! loader-example@1.0.0 build:
cross-env NODE_ENV=production babel src -d dist --copy-files
npm ERR! Exit status 2
Strange, can you provide more information or steps? Do you have src
/dist
directories?
No, I don't have src/dist directories, but nevertheless it shouldn't throw an error.
I've setup a blank project with no dependencies:
yarn init -y
yarn add --dev @webpack-contrib/defaults
--> @webpack-contrib/defaults": "^6.3.0No errors are thrown, but the script command is NOT created. In this case, no errors thrown is actually not good ;-)
3.) I add the script section by hand:
"scripts":{
"default" : "webpack-defaults"
}
Yarn default
Now I get the errors mentioned above:
errors: 1:)
'del-cli' is not recognized as an internal or external command, operable program or batch file. npm ERR! code ELIFECYCLE npm ERR! errno 1 npm ERR! nf@1.0.0 clean:
del-cli dist
npm ERR! Exit status 1 npm ERR! npm ERR! Failed at the nf@1.0.0 clean script. npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
2.)
babel: src does not exist npm ERR! code ELIFECYCLE npm ERR! errno 2 npm ERR! nf@1.0.0 build:
cross-env NODE_ENV=production babel src -d dist --copy-files
npm ERR! Exit status 2 npm ERR! npm ERR! Failed at the nf@1.0.0 build script.
3.)
Done. Happy webpacking!
Create test/loader.test.js (node:17420) UnhandledPromiseRejectionWarning: MrmError: copyFiles: source file not found: D:\xxx\Newfolder\node_modules\@webpack-contrib\defaults\templates\test\options.test.js at D:\xxx\Newfolder\node_modules\mrm-core\src\fs.js:32:10 at Array.forEach (
) at copyFiles (D:\xxx\Newfolder\node_modules\mrm-core\src\fs.js:29:21) at D:\xxx\Newfolder\node_modules\@webpack-contrib\defaults\dist\tasks\templates.js:26:7 (node:17420) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 1) (node:17420) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code. Done in 51.05s.
@evilebottnawi What triggers the post_install.js
in order to run?
Apparently id does not get triggered in my case.
What is use case for using webpack-defaults?
Use-case? You would use if you want to write a loader/plugin as it sets up many things upfront.
I don't have windows nearby, maybe we have some bugs with windows, I will try to look at that in next weekend (+ setup windows machine)
That's why I asked you, what triggers this postinstall.js
so i could take a look on my machine.
Yes, this is the mentioned file, but how does it get triggered/run, is there an install hook? Cause I can't see any on my side.
I met same issue on macOS 10.15.3, under ~/Documents/my-experiment
-ish directory has right permission.
There was actually no script written for me on a mac either.
npm init
npm install @webpack-contrib/defaults --save-dev
and the package was updated with the dependency but nothing was added to scripts.I did as Legends did and added the script myself. I got the UnhandledPromiseRejectionWarning error.
What worked for me macOS Big Sur 11.1 was to run:
npm init
npm install @webpack-contrib/defaults --save-dev
node_modules/@webpack-contrib/defaults/lib/post_install.js
npm run defaults
Thanks to @Legends for the hint in the PR.
I have the same issue in macOS Big Sur 11.4. I have to add the command defaults
by myself.
Expected Behavior
A created script command in package.json
Actual Behavior
nothing is created
Code
package.json
How Do We Reproduce?