I got the following lines in my packafe.json file (I just mirrored courses teacher)
"scripts": { "build:dev": "env NODE_ENV=development webpack --config webpack.config.js", "build:prod": "env NODE_ENV=production webpack --config webpack.config.js", "test": "echo "Error: no test specified" && exit 1" }
But unlike for him it doesn’t work for me, when I point my mouse to a build word (both of them), and click “Run Script” I get this error:
`Executing task: npm run build:dev
/usr/bin/bash: line 1: npm: command not found
* The terminal process "/usr/bin/bash '-c', 'npm run build:dev'" failed to launch (exit code: 127).
* Terminal will be reused by tasks, press any key to close it. `
I certainly see no clues about that issue, and can’t find them on the internet.
I have npm installed, and wondering what’s wrong. Maybe webpack is bad configured, but If I just run
Webpack
in my console it compiles successfully. Anyway here is my webpack.config.js file:
`const path = require('path');
const HTMLWebpackPlugin = require('html-webpack-plugin');
const NODE_ENV = process.env.NODE_ENV;
module.exports = {
resolve: {
extensions: ['.js', '.jsx', '.ts', '.tsx', '.json']
},
mode: NODE_ENV ? NODE_ENV : 'development',
entry: path.resolve(__dirname, 'src/index.jsx'),
output: {
path: path.resolve(__dirname, 'dist'),
filename: 'index.js'
},
module: {
rules: [{
test: /.[tj]sx?$/,
use: ['ts-loader']
}]
},
plugins: [
new HTMLWebpackPlugin({ template: path.resolve(__dirname, 'index.html') })
]
};`
By the way, I have one problem in my project that may somehow affect mentioned problem (that isn’t likely though). I’ve typed
tsc --init
to create tsconfig.json file and here is vscode problem warning:
`JSON schema for the TypeScript compiler’s configuration file
Cannot write file ‘/home/timothy/Desktop/WEB_COURSE/dist/index.js’ because it would overwrite input file.ts
Cannot write file ‘/home/timothy/Desktop/WEB_COURSE/dist/index.js’ because it would overwrite input file.ts`
I didn’t try to resolve this issue yet, because I really don’t know what even should I do.