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

Run Lint script in OS X Error #3

Closed
vitaliy-kotov opened this issue May 1, 2015 · 14 comments
Closed

Run Lint script in OS X Error #3

vitaliy-kotov opened this issue May 1, 2015 · 14 comments

Comments

@vitaliy-kotov
Copy link
Contributor

Source code for Chapter 03
Running npm run lint

in case if Lint finds nothing - ok
in case if Lint finds errors:

config/build.js
  1:1  error  Newline required at end of file but not found  eol-last

✖ 1 problem (1 error, 0 warnings)


npm ERR! Darwin 14.3.0
npm ERR! argv "node" "/usr/local/bin/npm" "run" "lint"
npm ERR! node v0.12.2
npm ERR! npm  v2.7.4
npm ERR! code ELIFECYCLE
npm ERR! [email protected] lint: `eslint . --ext .js --ext .jsx`
npm ERR! Exit status 1
npm ERR! 
npm ERR! Failed at the [email protected] lint script 'eslint . --ext .js --ext .jsx'.
npm ERR! This is most likely a problem with the kanban_app package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     eslint . --ext .js --ext .jsx
npm ERR! You can get their info via:
npm ERR!     npm owner ls kanban_app
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /Users/xxx/samples/webpack_react/project_source/03_developing_with_webpack/kanban_app/npm-debug.log

if I run eslint directly without script eslint . - goes fine
looks like some script - OS X related problem

0 info it worked if it ends with ok
1 verbose cli [ 'node', '/usr/local/bin/npm', 'run', 'lint' ]
2 info using [email protected]
3 info using [email protected]
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info prelint [email protected]
6 info lint [email protected]
7 verbose unsafe-perm in lifecycle true
8 info [email protected] Failed to exec lint script
9 verbose stack Error: [email protected] lint: `eslint . --ext .js --ext .jsx`
9 verbose stack Exit status 1
9 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:213:16)
9 verbose stack     at EventEmitter.emit (events.js:110:17)
9 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:14:12)
9 verbose stack     at ChildProcess.emit (events.js:110:17)
9 verbose stack     at maybeClose (child_process.js:1015:16)
9 verbose stack     at Process.ChildProcess._handle.onexit (child_process.js:1087:5)
10 verbose pkgid [email protected]
11 verbose cwd /Users/xxx/samples/webpack_react/project_source/03_developing_with_webpack/kanban_app
12 error Darwin 14.3.0
13 error argv "node" "/usr/local/bin/npm" "run" "lint"
14 error node v0.12.2
15 error npm  v2.7.4
16 error code ELIFECYCLE
17 error [email protected] lint: `eslint . --ext .js --ext .jsx`
17 error Exit status 1
18 error Failed at the [email protected] lint script 'eslint . --ext .js --ext .jsx'.
18 error This is most likely a problem with the kanban_app package,
18 error not with npm itself.
18 error Tell the author that this fails on your system:
18 error     eslint . --ext .js --ext .jsx
18 error You can get their info via:
18 error     npm owner ls kanban_app
18 error There is likely additional logging output above.
19 verbose exit [ 1, true ]
@bebraw
Copy link
Member

bebraw commented May 1, 2015

Once Webpack 2.0 goes out I'll eliminate config/build.js etc. and use a cleaner approach. Webpack 2.0 makes it easy to pass variables to the configuration. The problem is I don't know when it's going to be released.

I suppose I could do this already with export NODE_ENV=production && webpack .... Maybe that's the right fix now that I think of it. That would eliminate the issue and keep the project a little tidier. It should be easy to port to Webpack 2.0 once it's out.

Thanks for the feedback! It's very valuable. 👍

bebraw added a commit that referenced this issue May 2, 2015
This probably isn't the ideal solution but it's better than earlier. At
least now there are no extra modules hanging around.

Related to #3.
@bebraw
Copy link
Member

bebraw commented May 2, 2015

@vitaliy-kotov Can you have a look now? The configuration bit should be nicer now (no need for extra modules).

@vitaliy-kotov
Copy link
Contributor Author

@bebraw npm run lint same behavior, same error, it looks like running eslint from child process problem. One file config looks nice thou.

@vitaliy-kotov
Copy link
Contributor Author

@bebraw example works fine after removing eslint preloader from Config

@vitaliy-kotov
Copy link
Contributor Author

@bebraw global eslint . still runs fine

@bebraw
Copy link
Member

bebraw commented May 2, 2015

@vitaliy-kotov Got it! We can do a little trick like "lint": "eslint . --ext .js --ext .jsx || true" at scripts. Then you get

config/index.js
  42:1  error  Newline required at end of file but not found  eol-last

✖ 1 problem (1 error, 0 warnings)

which is much nicer!

@bebraw
Copy link
Member

bebraw commented May 2, 2015

Here's a thread for reference, npm/npm#6124 .

@bebraw
Copy link
Member

bebraw commented May 2, 2015

The potential problem with || true is that it won't work with tooling like Travis CI since those expect an exit code (1) to signify failure. I'll do some extra research on this.

Note that the errors we get on Webpack side at npm run dev are quite nice.

@vitaliy-kotov
Copy link
Contributor Author

@bebraw || true helped with npm run lint but eslint preloader still has the error

npm run dev

> [email protected] dev /Users/xxx/samples/kanban_app
> TARGET=dev webpack-dev-server --config config --devtool eval --progress --colors --hot --content-base build

 70% 1/1 build moduleshttp://localhost:8080/webpack-dev-server/
webpack result is served from /
content is served from /Users/xxx/samples/kanban_app/build
Hash: 37043390c565879c0019  
Version: webpack 1.8.11
Time: 1151ms
chunk    {0} bundle.js (main) 2.64 kB [rendered]
    [0] multi main 40 bytes {0} [built] [1 error]
    [1] (webpack)/hot/dev-server.js 1.79 kB {0} [built]
    [3] (webpack)/hot/log-apply-result.js 813 bytes {0} [built]

ERROR in Loader /Users/xxx/samples/kanban_app/node_modules/eslint/lib/api.js didn't return a function
 @ multi main
webpack: bundle is now VALID.

@bebraw
Copy link
Member

bebraw commented May 2, 2015

@vitaliy-kotov It looks like it's trying to use eslint as the loader instead of eslint-loader. Can you try loader: 'eslint-loader', kind of declaration for eslint-loader?

Maybe I should use -loader suffix everywhere to avoid confusion. It's not a cool error to debug.

@vitaliy-kotov
Copy link
Contributor Author

@bebraw now goes fine. Issue is closed.

@bebraw
Copy link
Member

bebraw commented May 2, 2015

Ok, I'll change the book to use eslint-loader explicitly. That seems like a
good idea in this case.

I'll also add a mention about that piping trick.

Thanks. :)

On Saturday, 2 May 2015, Vitaliy Kotov [email protected] wrote:

Closed #3 #3.


Reply to this email directly or view it on GitHub
#3 (comment).

bebraw added a commit that referenced this issue May 3, 2015
bebraw added a commit that referenced this issue May 3, 2015
kamotos added a commit to kamotos/webpack_react that referenced this issue Feb 25, 2016
Hi,

I think 'eslint-loader' should be used instead `eslint`. The later will give the following error.


```
path/to/eslint/lib/api.js didn't return a function
 @ multi main
webpack: bundle is now VALID.
```

Someone talked about it as well in survivejs#3.

I'm new to eslint, so I hope this is correct.
@crisu83
Copy link

crisu83 commented Jun 18, 2016

@bebraw I also stumbled on this when I forgot to install the eslint-loader in one of my projects. I am definitely going to use -loader explicitly from now on. :)

@bebraw
Copy link
Member

bebraw commented Jun 19, 2016

@crisu83 That's a valid point. There's actually a task for this at webpack-validator in case someone wants to tackle it. See js-dxtools/webpack-validator#42 .

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

3 participants