Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No script command created on Windows 10 #181

Open
Legends opened this issue Jan 7, 2020 · 15 comments
Open

No script command created on Windows 10 #181

Legends opened this issue Jan 7, 2020 · 15 comments

Comments

@Legends
Copy link

Legends commented Jan 7, 2020

  • Operating System:
  • Node Version: v12.13.0
  • NPM Version: 5.8.0, but I am using yarn (v1.7.0) not npm
  • webpack Version: "webpack": "^4.41.5"
  • @webpack-contrib/defaults Version: "@webpack-contrib/defaults": "^6.3.0",

Expected Behavior

A created script command in package.json

Actual Behavior

nothing is created

Code

// webpack.config.js
// If your code blocks are over 20 lines, please paste a link to a gist
// (https://gist.github.com).
// additional code, HEY YO remove this block if you don't need it

package.json

{
  "name": "test",
  "version": "1.0.0",
  "main": "index.js",
  "license": "MIT",
  "devDependencies": {
    "webpack": "^4.41.5",
    "webpack-cli": "^3.3.10",
    "@webpack-contrib/defaults": "^6.3.0"
  },
  "dependencies": {
    "lodash": "^4.17.15",
    "tmp": "^0.1.0"
  }
}

How Do We Reproduce?

@Legends Legends closed this as completed Jan 7, 2020
@Legends Legends reopened this Jan 7, 2020
@Legends
Copy link
Author

Legends commented Jan 7, 2020

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"
}

@Legends Legends changed the title No script command created No script command created on Windows 10 Jan 7, 2020
@Legends
Copy link
Author

Legends commented Jan 7, 2020

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

@alexander-akait
Copy link
Member

Strange, can you provide more information or steps? Do you have src/dist directories?

@Legends
Copy link
Author

Legends commented Jan 9, 2020

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:

  1. yarn init -y
  2. yarn add --dev @webpack-contrib/defaults --> @webpack-contrib/defaults": "^6.3.0

No 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"
   }
  1. 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.

@Legends
Copy link
Author

Legends commented Jan 14, 2020

@evilebottnawi What triggers the post_install.js in order to run?
Apparently id does not get triggered in my case.

@alexander-akait
Copy link
Member

What is use case for using webpack-defaults?

@Legends
Copy link
Author

Legends commented Jan 15, 2020

Use-case? You would use if you want to write a loader/plugin as it sets up many things upfront.

@alexander-akait
Copy link
Member

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)

@Legends
Copy link
Author

Legends commented Jan 15, 2020

That's why I asked you, what triggers this postinstall.js so i could take a look on my machine.

@alexander-akait
Copy link
Member

@Legends
Copy link
Author

Legends commented Jan 15, 2020

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.

@ash-r1
Copy link

ash-r1 commented Jul 18, 2020

I met same issue on macOS 10.15.3, under ~/Documents/my-experiment-ish directory has right permission.

@floralWallpaper
Copy link

floralWallpaper commented Jul 21, 2020

There was actually no script written for me on a mac either.

  • I started a new project with npm init
  • I ran 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.

@steinybot
Copy link

steinybot commented Jan 28, 2021

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.

@peterhpchen
Copy link

I have the same issue in macOS Big Sur 11.4. I have to add the command defaults by myself.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

6 participants