problem with running eslint with npm node js - node.js

eslint . --ext .js
Error: .eslintrc:
Environment key "es2021" is unknown
at Object.keys.forEach.id (Image api/node_modules/eslint/lib/shared/config-validator.js:169:19)
at Array.forEach (<anonymous>)
at validateEnvironment (Image api/node_modules/eslint/lib/shared/config-validator.js:163:30)
at validateConfigArray (Image api/node_modules/eslint/lib/shared/config-validator.js:334:9)
at CascadingConfigArrayFactory._finalizeConfigArray (Image api/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:417:13)
at CascadingConfigArrayFactory.getConfigArrayForFile (Image api/node_modules/eslint/lib/cli-engine/cascading-config-array-factory.js:271:21)
at FileEnumerator._iterateFilesRecursive (Image api/node_modules/eslint/lib/cli-engine/file-enumerator.js:396:49)
at _iterateFilesRecursive.next (<anonymous>)
at FileEnumerator.iterateFiles (Image api/node_modules/eslint/lib/cli-engine/file-enumerator.js:251:49)
at iterateFiles.next (<anonymous>)
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! image-api#1.0.0 lint: eslint . --ext .js
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the image-api#1.0.0 lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/marwan/.npm/_logs/2022-01-10T23_00_43_567Z-debug.log
.eslintrc
{
"env": {
"browser": true,
"es2021": true
},
"parser": "#typescript-eslint/parser",
"parserOptions": {
"ecmaVersion": 12,
"sourceType": "module"
},
"plugins": [
"#typescript-eslint"
],
"rules": {
"indent": [
"error",
2
],
"linebreak-style": [
"error",
"unix"
],
"quotes": [
"error",
"single"
],
"semi": [
"error",
"always"
],
"no-multiple-empty-lines": [
2,
{ "max": 1, "maxEOF": 0, "maxBOF": 0 }
],
"no-trailing-spaces": "error",
"import/no-extraneous-dependencies": 0
}
}

The environment es2021 was added with ESLint 8 (ESLint 7 does not have it). The error message is a hint that you are using an older version of ESLint.
Look into your package.json, update the ESLint version to >= 8, then run npm install.

Related

can't run a server because node package errors

M1 Mac user here. Trying to run a server to work on website in dev environment, but something is off with node packages and maybe next.js versioning?.. I tried updating them with npm install but I keep running into this error:
bash-3.2$ npm install
npm ERR! code ERESOLVE
npm ERR! ERESOLVE could not resolve
npm ERR!
npm ERR! While resolving: pulse#0.1.0
npm ERR! Found: next#10.0.7
npm ERR! node_modules/next
npm ERR! next#"12.1.6" from the root project
npm ERR!
npm ERR! Could not resolve dependency:
npm ERR! next#"12.1.6" from the root project
npm ERR!
npm ERR! Conflicting peer dependency: react#18.1.0
npm ERR! node_modules/react
npm ERR! peer react#"^17.0.2 || ^18.0.0-0" from next#12.1.6
npm ERR! node_modules/next
npm ERR! next#"12.1.6" from the root project
npm ERR!
npm ERR! Fix the upstream dependency conflict, or retry
npm ERR! this command with --force, or --legacy-peer-deps
npm ERR! to accept an incorrect (and potentially broken) dependency resolution.
npm ERR!
npm ERR! See /Users/artemhb/.npm/eresolve-report.txt for a full report.
npm ERR! A complete log of this run can be found in:
npm ERR! /Users/artemhb/.npm/_logs/2022-05-28T21_24_07_001Z-debug-0.log
This is what happens when I try running a server anyway:
bash-3.2$ npm run dev
> pulse#0.1.0 dev
> next dev
Browserslist: caniuse-lite is outdated. Please run:
npx browserslist#latest --update-db
Why you should do it regularly:
https://github.com/browserslist/browserslist#browsers-data-updating
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: Package subpath './lib/parser' is not defined by "exports" in /Users/artemhb/Documents/hbdev/impulse/node_modules/postcss/package.json
at new NodeError (node:internal/errors:372:5)
at throwExportsNotFound (node:internal/modules/esm/resolve:439:9)
at packageExportsResolve (node:internal/modules/esm/resolve:718:3)
at resolveExports (node:internal/modules/cjs/loader:482:36)
at Function.Module._findPath (node:internal/modules/cjs/loader:522:31)
at Function.Module._resolveFilename (node:internal/modules/cjs/loader:919:27)
at Function.Module._load (node:internal/modules/cjs/loader:778:27)
at Module.require (node:internal/modules/cjs/loader:999:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.552 (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11590)
at __nccwpck_require__ (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11735)
at Object.270 (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:400)
at __nccwpck_require__ (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11735)
at Object.327 (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:260)
at __nccwpck_require__ (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:11735)
at Object.845 (/Users/artemhb/Documents/hbdev/impulse/node_modules/next/dist/compiled/postcss-scss/scss-syntax.js:1:3733) {
code: 'ERR_PACKAGE_PATH_NOT_EXPORTED'
Any recommendations on what to do here? Thanks!
UPD: Before running a server, I tried to install / update new packages, and here's what I got –
# npm resolution error report
2022-05-28T22:19:21.808Z
While resolving: pulse#0.1.0
Found: react#18.1.0
node_modules/react
react#"18.1.0" from the root project
Could not resolve dependency:
peer react#"^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0" from react-lazyload#3.2.0
node_modules/react-lazyload
react-lazyload#"^3.2.0" from the root project
Fix the upstream dependency conflict, or retry
this command with --force, or --legacy-peer-deps
to accept an incorrect (and potentially broken) dependency resolution.
Raw JSON explanation object:
{
"code": "ERESOLVE",
"current": {
"name": "react",
"version": "18.1.0",
"whileInstalling": {
"name": "pulse",
"version": "0.1.0",
"path": "/Users/artemhb/Documents/hbdev/impulse"
},
"location": "node_modules/react",
"isWorkspace": false,
"dependents": [
{
"type": "prod",
"name": "react",
"spec": "18.1.0",
"from": {
"location": "/Users/artemhb/Documents/hbdev/impulse"
}
}
]
},
"currentEdge": {
"type": "prod",
"name": "react",
"spec": "18.1.0",
"from": {
"location": "/Users/artemhb/Documents/hbdev/impulse"
}
},
"edge": {
"type": "peer",
"name": "react",
"spec": "^0.14.0 || ^15.0.0 || ^16.0.0 || ^17.0.0",
"error": "INVALID",
"from": {
"name": "react-lazyload",
"version": "3.2.0",
"whileInstalling": {
"name": "pulse",
"version": "0.1.0",
"path": "/Users/artemhb/Documents/hbdev/impulse"
},
"location": "node_modules/react-lazyload",
"isWorkspace": false,
"dependents": [
{
"type": "prod",
"name": "react-lazyload",
"spec": "^3.2.0",
"from": {
"location": "/Users/artemhb/Documents/hbdev/impulse"
}
}
]
}
},
"strictPeerDeps": false,
"force": false
}

Error Firebase cli cloud function deploy. npm ERR! Failed at the functions# lint script

I am trying to deploy a typescript cloud function to the google cloud using firebase cli. My reason for doing it like this is because I had a javascript funtions which gave me warnings about firebase environment variable being estimated. So using the firebase cli worked.
Now I have another function in typescript.
npm: 6.14.15
firebase: 9.19.0
node: 14.17.6
Here is the code.
"use strict";
import cbor = require("cbor");
import * as admin from "firebase-admin";
import * as functions from "firebase-functions";
import iot = require("#google-cloud/iot");
const client = new iot.v1.DeviceManagerClient();
// start cloud function
exports.configFirestorev2 = functions
.region("europe-west1")
.firestore
.document("Configs/{deviceId}")
.onWrite(async (change: functions.Change<admin.firestore.DocumentSnapshot>,
context?: functions.EventContext) => {
if (context) {
console.log(context.params.deviceId);
const request = generateRequest(context.params.deviceId, change.after.data(), false);
return client.modifyCloudToDeviceConfig(request);
} else {
throw (Error("no context from trigger"));
}
});
function generateRequest(deviceId: string, configData: any, isBinary: boolean) {
const formattedName = client.devicePath(process.env.GCLOUD_PROJECT!, functions.config().iot.core.region, functions.config().iot.core.registry, deviceId);
let dataValue;
if (isBinary) {
const encoded = cbor.encode(configData);
dataValue = encoded.toString("base64");
} else {
dataValue = Buffer.from(JSON.stringify(configData)).toString("base64");
}
return {
name: formattedName,
binaryData: dataValue,
};
}
here is the .eslintrc.js
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:#typescript-eslint/recommended",
],
parser: "#typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
],
plugins: [
"#typescript-eslint",
"import",
],
rules: {
"quotes": ["error", "double"],
"import/no-unresolved": 0,
},
};
Here is the package.json file
{
"name": "functions",
"scripts": {
"lint": "eslint --ext .js,.ts .",
"build": "tsc",
"serve": "npm run build && firebase emulators:start --only functions",
"shell": "npm run build && firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "14"
},
"main": "lib/index.js",
"dependencies": {
"firebase-admin": "^9.8.0",
"firebase-functions": "^3.14.1",
"#google-cloud/iot": "2.0.0",
"#types/cbor": "^5.0.0",
"cbor": "^5.0.2"
},
"devDependencies": {
"#typescript-eslint/eslint-plugin": "^3.9.1",
"#typescript-eslint/parser": "^3.8.0",
"eslint": "^7.6.0",
"eslint-config-google": "^0.14.0",
"eslint-plugin-import": "^2.22.0",
"firebase-functions-test": "^0.2.0",
"typescript": "^3.8.0"
},
"private": true
}
when I try to deploy it using firebase deploy --only functions
I get an error see the terminal log.
PS C:\firebase\configFirestore\functions> firebase deploy --only functions
=== Deploying to 'pti-tag-copy'...
i deploying functions
Running command: npm --prefix functions run lint && npm --prefix functions run build
> functions# lint C:\firebase\configFirestore\functions
> tslint -p tslint.json
'tslint' is not recognized as an internal or external command,
operable program or batch file.
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! functions# lint: `tslint -p tslint.json`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the functions# lint script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! C:\Users\Shabir\AppData\Roaming\npm-cache\_logs\2021-10-06T06_44_06_259Z-debug.log
events.js:377
throw er; // Unhandled 'error' event
^
Error: spawn npm --prefix functions run lint && npm --prefix functions run build ENOENT
at notFoundError (C:\Users\Shabir\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:6:26)
at verifyENOENT (C:\Users\Shabir\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:40:16)
at ChildProcess.cp.emit (C:\Users\Shabir\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:27:25)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12)
Emitted 'error' event on ChildProcess instance at:
at ChildProcess.cp.emit (C:\Users\Shabir\AppData\Roaming\npm\node_modules\firebase-tools\node_modules\cross-env\node_modules\cross-spawn\lib\enoent.js:30:37)
at Process.ChildProcess._handle.onexit (internal/child_process.js:277:12) {
code: 'ENOENT',
errno: 'ENOENT',
syscall: 'spawn npm --prefix functions run lint && npm --prefix functions run build',
path: 'npm --prefix functions run lint && npm --prefix functions run build',
spawnargs: []
}
Error: functions predeploy error: Command terminated with non-zero exit code1
and here is a complete debug log
0 info it worked if it ends with ok
1 verbose cli [
1 verbose cli 'C:\\Program Files\\nodejs\\node.exe',
1 verbose cli 'C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js',
1 verbose cli '--prefix',
1 verbose cli 'functions',
1 verbose cli 'run',
1 verbose cli 'lint'
1 verbose cli ]
2 info using npm#6.14.15
3 info using node#v14.17.6
4 verbose run-script [ 'prelint', 'lint', 'postlint' ]
5 info lifecycle functions#~prelint: functions#
6 info lifecycle functions#~lint: functions#
7 verbose lifecycle functions#~lint: unsafe-perm in lifecycle true
8 verbose lifecycle functions#~lint: PATH: C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\node-gyp-bin;C:\firebase\configFirestore\functions\node_modules\.bin;C:\Users\Shabir\AppData\Local\cloud-code\installer\google-cloud-sdk\bin;C:\Users\Shabir\AppData\Local\Programs\Python\Python39\Scripts\;C:\Users\Shabir\AppData\Local\Programs\Python\Python39\;C:\Program Files\Common Files\Oracle\Java\javapath;C:\Windows\system32;C:\Windows;C:\Windows\System32\Wbem;C:\Windows\System32\WindowsPowerShell\v1.0\;C:\Windows\System32\OpenSSH\;C:\Program Files\NVIDIA Corporation\NVIDIA NvDLISR;C:\Program Files (x86)\NVIDIA Corporation\PhysX\Common;C:\ProgramData\chocolatey\bin;C:\Program Files (x86)\Bitvise SSH Client;C:\Program Files\PuTTY\;C:\Program Files\Git\cmd;C:\Program Files\php-8.0.3-Win32-vs16-x64;C:\Program Files\dotnet\;C:\Program Files\Go\bin;C:\WINDOWS\system32;C:\WINDOWS;C:\WINDOWS\System32\Wbem;C:\WINDOWS\System32\WindowsPowerShell\v1.0\;C:\WINDOWS\System32\OpenSSH\;C:\Program Files\Intel\Intel(R) Memory and Storage Tool\;C:\Program Files\nodejs\;C:\Program Files\Docker\Docker\resources\bin;C:\ProgramData\DockerDesktop\version-bin;C:\Program Files (x86)\Google\Cloud SDK\google-cloud-sdk\bin;C:\Program Files\MinGW\bin;C:\Users\Shabir\AppData\Local\Microsoft\WindowsApps;;C:\Users\Shabir\AppData\Local\Programs\Microsoft VS Code\bin;C:\Users\Shabir\AppData\Roaming\cabal\bin;C:\ProgramData\chocolatey\lib\ghc\tools\ghc-8.10.4\bin;C:\tools\msys64;C:\Users\Shabir\go\bin;C:\Users\Shabir\AppData\Roaming\npm
9 verbose lifecycle functions#~lint: CWD: C:\firebase\configFirestore\functions
10 silly lifecycle functions#~lint: Args: [ '/d /s /c', 'tslint -p tslint.json' ]
11 silly lifecycle functions#~lint: Returned: code: 1 signal: null
12 info lifecycle functions#~lint: Failed to exec lint script
13 verbose stack Error: functions# lint: `tslint -p tslint.json`
13 verbose stack Exit status 1
13 verbose stack at EventEmitter.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\index.js:332:16)
13 verbose stack at EventEmitter.emit (events.js:400:28)
13 verbose stack at ChildProcess.<anonymous> (C:\Program Files\nodejs\node_modules\npm\node_modules\npm-lifecycle\lib\spawn.js:55:14)
13 verbose stack at ChildProcess.emit (events.js:400:28)
13 verbose stack at maybeClose (internal/child_process.js:1055:16)
13 verbose stack at Process.ChildProcess._handle.onexit (internal/child_process.js:288:5)
14 verbose pkgid functions#
15 verbose cwd C:\firebase\configFirestore
16 verbose Windows_NT 10.0.22468
17 verbose argv "C:\\Program Files\\nodejs\\node.exe" "C:\\Program Files\\nodejs\\node_modules\\npm\\bin\\npm-cli.js" "--prefix" "functions" "run" "lint"
18 verbose node v14.17.6
19 verbose npm v6.14.15
20 error code ELIFECYCLE
21 error errno 1
22 error functions# lint: `tslint -p tslint.json`
22 error Exit status 1
23 error Failed at the functions# lint script.
23 error This is probably not a problem with npm. There is likely additional logging output above.
24 verbose exit [ 1, true ]
I didn't managed to reproduce your issue but I was able to deploy your function in a Debian environment by following the next steps:
I run the following command firebase init functions (I picked TS and selected yes in all options)
cd functions
npm install cbor
npm install #google-cloud/iot
Copied your function inside the directory functions/src/index.ts
I modified the.eslintrc.js.
I run firebase deploy --only functions
In the .eslintrc.js I added the following lines in the rules section:
"max-len": ["error", {"code": 200}],
"require-jsdoc": 0,
Here is the final .eslintrc.js:
module.exports = {
root: true,
env: {
es6: true,
node: true,
},
extends: [
"eslint:recommended",
"plugin:import/errors",
"plugin:import/warnings",
"plugin:import/typescript",
"google",
"plugin:#typescript-eslint/recommended",
],
parser: "#typescript-eslint/parser",
parserOptions: {
project: ["tsconfig.json", "tsconfig.dev.json"],
sourceType: "module",
},
ignorePatterns: [
"/lib/**/*", // Ignore built files.
], plugins: [
"#typescript-eslint",
"import",
],
rules: {
"quotes": ["error", "double"],
"import/no-unresolved": 0,
"max-len": ["error", {"code": 200}],
"require-jsdoc": 0,
},
};
Could you verify that you followed this steps?
EDIT
As stated in the comments. The issue was solved by following the steps in this answer. In summary, what OP did was set tsconfigRootDir to __dirname in the .eslintrc.js file:
module.exports = {
// ...
parserOptions: {
project: "tsconfig.json",
tsconfigRootDir: __dirname,
sourceType: "module",
},
// ...
}

Nodemon doesn't start the server

I installed nodemon to devDependencies and set the script "start" : "nodemon server.js". However, when I do npm start, it throws me this error:
Error: Cannot find module 'C:\Users\win10\Desktop\nodemon\bin\nodemon.js'
at Function.Module._resolveFilename (internal/modules/cjs/loader.js:880:15)
at Function.Module._load (internal/modules/cjs/loader.js:725:27)
at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:72:12)
at internal/main/run_main_module.js:17:47 {
code: 'MODULE_NOT_FOUND',
requireStack: []
npm ERR! code ELIFECYCLE
npm ERR! errno 1
npm ERR! question-answer-rest-api#1.0.0 start: `nodemon server.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the question-answer-rest-api#1.0.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
My package.json
{
"name": "question-answer-rest-api",
"version": "1.0.0",
"description": "Back end project for practice",
"main": "server.js",
"scripts": {
"start": "nodemon server.js"
},
"keywords": [
"Express",
"Nodejs",
"Mongoose",
"Api"
],
"author": "Cihan Özcan",
"license": "MIT",
"dependencies": {
"express": "^4.17.1"
},
"devDependencies": {
"nodemon": "^2.0.7"
}
}
I also filled in server.js and tried that way but it didn't work.
My server.js file
const express = require('express');
const app = express();
const PORT = 5000
app.listen(PORT, () => {
console.log(`Server started on port ${PORT}`)
})
There are no any file in the folder. I couldn't find similar error in SO. I installed nodemon as global and checked the global environment in pc. There is no problem with it.
What is the problem ?
Try
npm uninstall nodemon
Then
npm install -g nodemon
It should works

cannot start react app with the npm start command

I am trying to run my react-ebay-clone but the
npm start
command does not work. Instead react throws this error
freduah#freduah:~/react-ebay-clone/react-ebay-clone$ npm start
> react-ebay-clone#0.1.0 start /home/freduah/react-ebay-clone/react-ebay-clone
> react-scripts start
sh: 1: react-scripts: not found
npm ERR! code ELIFECYCLE
npm ERR! syscall spawn
npm ERR! file sh
npm ERR! errno ENOENT
npm ERR! react-ebay-clone#0.1.0 start: `react-scripts start`
npm ERR! spawn ENOENT
npm ERR!
npm ERR! Failed at the react-ebay-clone#0.1.0 start script.
npm ERR! This is probably not a problem with npm. There is likely additional logging output above.
npm ERR! A complete log of this run can be found in:
npm ERR! /home/freduah/.npm/_logs/2020-10-26T19_24_02_415Z-debug.log
freduah#freduah:~/react-ebay-clone/react-ebay-clone$
Below Is My package.json file
{
"name": "react-ebay-clone",
"version": "0.1.0",
"private": true,
"dependencies": {
"#testing-library/jest-dom": "^5.11.5",
"#testing-library/react": "^11.1.0",
"#testing-library/user-event": "^12.1.10",
"react": "^17.0.1",
"react-dom": "^17.0.1",
"react-scripts": "4.0.0",
"web-vitals": "^0.2.4"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},
"eslintConfig": {
"extends": [
"react-app",
"react-app/jest"
]
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
}
}
I have found this previous stack overflow,
npm start error with create-react-app.

Webpack error - can't resolve loader in 'tmp/build...'

I recently added the eslint and eslint-loader NPM modules as dev dependencies to my React app (with Webpack) - all is well when I am running my development server locally. However, when I try to build the production release locally, it fails with the following error:
npm ERR! Darwin 16.7.0
npm ERR! argv "/Users/user/.nvm/versions/node/v6.11.1/bin/node" "/Users/user/.nvm/versions/node/v6.11.1/bin/npm" "run" "build:client"
npm ERR! node v6.11.1
npm ERR! npm v3.10.10
npm ERR! code ELIFECYCLE
npm ERR! App#0.0.1 build:client: `webpack`
npm ERR! Exit status 2
npm ERR!
npm ERR! Failed at the App#0.0.1 build:client script 'webpack'.
On a whim, I also tried pushing to Heroku, where I got a more helpful error:
ERROR in Entry module not found: Error: Can't resolve 'eslint-loader' in '/tmp/build_5f502b6d28fee058cbe484b873b6e7cb'
npm ERR! code ELIFECYCLE
npm ERR! errno 2
npm ERR! App#0.0.1 build:client: `webpack`
npm ERR! Exit status 2
So this is the part where I admit that I am a bit baffled by Webpack, and would greatly appreciate some guidance and clarification, if that can be offered. I've seen others with a similar issue, but never referring to the '/tmp/build...' directory.
So first off, here are the scripts and some other relevant bits in my package.json:
"scripts": {
"start": "if-env NODE_ENV=production && npm run start:prod || npm run start:dev",
"start:prod": "node server.bundle.js",
"start:dev": "concurrently --prefix \"[{name}]\" -k \"webpack -d --watch --colors\" \"nodemon index.js\" -n \"WEBPACK,NODEMON\" --content-base public/",
"build:client": "webpack",
"build:server": "webpack --config webpack.server.config.js",
"build": "NODE_ENV=production npm run build:client && npm run build:server",
"postinstall": "npm run build"
},
"dependencies": {
"webpack": "^2.6.0"
},
"devDependencies": {
"eslint": "^4.4.1",
"eslint-loader": "^1.9.0",
"eslint-plugin-babel": "^4.1.2",
"eslint-plugin-react": "^7.1.0"
"webpack-dev-server": "^2.4.5"
}
As the errors say, build:client is where this is failing...
And from webpack.config.js:
"module": {
"loaders": [
{
"exclude": /node_modules/,
"loader": "babel-loader",
"query": { "presets": ["react", "es2015", "stage-2"] },
"test": /\.jsx?$/
},
{
"exclude": /node_modules/,
"loader": "babel-loader",
"test": /\.js$/
},
{
"enforce": "pre",
"exclude": /node_modules/,
"loader": "eslint-loader",
"query": { "presets": ["react", "es2015", "stage-2"] },
"test": /\.jsx$/
},
{
"enforce": "pre",
"exclude": /node_modules/,
"loader": "eslint-loader",
"test": /\.js$/
}
]
}
If I comment out the sections referring to eslint-loader in the config, then it builds just fine, so as Heroku so keenly observed, the problem must be with those lines. Can anyone suggest a fix for this problem? I'm not sure that I really understand what is going wrong, let alone how to resolve it.
Edit Here is my complete webpack.config.js:
const webpack = require("webpack")
module.exports = {
"entry": "./src/index.jsx",
"module": {
"loaders": [
{
"exclude": /node_modules/,
"loader": "babel-loader",
"query": { "presets": ["react", "es2015", "stage-2"] },
"test": /\.jsx?$/
},
{
"exclude": /node_modules/,
"loader": "babel-loader",
"test": /\.js$/
},
{
"enforce": "pre",
"exclude": /node_modules/,
"loader": "eslint-loader",
"query": { "presets": ["react", "es2015", "stage-2"] },
"test": /\.jsx$/
},
{
"enforce": "pre",
"exclude": /node_modules/,
"loader": "eslint-loader",
"test": /\.js$/
}
]
},
"output": {
"filename": "./public/bundle.js",
"publicPath": "/"
},
"plugins": [
new webpack.DefinePlugin({
"API_URL": JSON.stringify(process.env.API_URL || "http://localhost:4000/api/v1"),
"IS_STAGING": JSON.stringify(process.env.IS_STAGING || "false"),
"NODE_ENV": JSON.stringify(process.env.NODE_ENV || "development")
})
]
}
Thanks to #Marek and #archae0pteryx for their thoughts on this - I came up with a fix, though it may not be optimal...
Basically, I created a webpack.dev.config.js file that included the references to eslint-loader... which is just fine, since I only want to use the linting in local development. Then I removed those references from my main config file updated package.json to use the dev config in local development, and it was all good.
I had the same problem, but for me, that wasn't solved in such way.
I solved it using this answer by EvHaus
https://github.com/babel/babel-loader/issues/166#issuecomment-184763126
This is the solution:
plugins: [
require.resolve("babel-plugin-add-module-exports"),
require.resolve("babel-plugin-transform-decorators-legacy")
],
presets: [
require.resolve("babel-preset-es2015"),
require.resolve("babel-preset-stage-0"),
require.resolve("babel-preset-react")
]
I think your problem may be that you have EsLint in devDependencies. If I remember correctly Heroku installs only dependencies of your app. Try moving EsLint into dependencies.

Resources