I am learning Node and working on a existing project which has build script as below:
"build": "npm run clean && ./node_modules/.bin/webpack --env=production --progress --profile --colors --display-optimization-bailout"
I did the npm install as per the instruction, but the build command gives an error below:
$ npm run build
> npm run clean && ./node_modules/.bin/webpack --env=development --progress --profile --colors --display-optimization-bailout
> rimraf build
'.' is not recognized as an internal or external command,
operable program or batch file.
Any idea on what I could be missing and how I can troubleshoot the problem, I am on windows pc. Thanks!
Wrap the path to webpack in JSON escaped double quotes, i.e. \"...\".
For instance:
"build": "npm run clean && \"./node_modules/.bin/webpack\" --env=production --progress --profile --colors --display-optimization-bailout"
^^ ^^
Related
Please teach me the solution how to run the preact application using webpack-dev-server.
I am getting the following errors in "npm run start"
package.json file
npm run start
I fixed my error by changing "start:root" and "start:query" as follows.
"start:root": "SET NODE_ENV=development && webpack -p --config webpack.config.root.js --watch",
"start:query": "SET NODE_ENV=development && webpack -p --config webpack.config.query.js --watch",
Inside package.json the build script is something like:
"build": "REACT_APP_RELEASE=$npm_package_version REACT_APP_COMMIT_REF=$COMMIT_REF react-scripts build && echo $COMMIT_REF >> build/version.txt",
When I run the command yarn build I get following error:
'REACT_APP_RELEASE' is not recognized as an internal or external command, operable program or batch file. error Command failed with exit code 1.
What should I do?
Step 1
Install the cross-env module.
npm install cross-env
or
yarn add cross-env
Step 2
Add cross-env before REACT_APP_RELEASE variable in the build script. If REACT_APP_RELEASE variable is in the middle of your build script you have to always add cross-env just before the REACT_APP_RELEASE variable.
Full command:
"build": "cross-env REACT_APP_RELEASE=$npm_package_version REACT_APP_COMMIT_REF=$COMMIT_REF react-scripts build && echo $COMMIT_REF >> build/version.txt",
In my docker file, I want to run test script inside it after app is up in Docker dev version. Problem is when I created a bash script and add like that, test script is not working.
Here is my package json file:
"scripts": {
"build": "./node_modules/babel-cli/bin/babel.js src --out-dir lib --copy-files lib --plugins transform-react-jsx --presets es2015",
"bundle": "./node_modules/browserify/bin/cmd.js lib/client.js -o public/js/bundle.js",
"start": "npm run build && npm run bundle && node lib/server.js",
"test": "mocha ./src/*.test.js"
},
and here is bash script file
#!/bin/bash
npm start
npm run start
npm test
npm run test
Please let me know how to fix it, thanks much.
#!/bin/bash
npm run build
npm run bundle
forever start ./lib/server.js
npm test
I've found solution that I need to install forever or pm2 first.
I am trying to build a folder with the name of build which will gonna contains number of map files and JavaScript files. But i'm getting an issue shown below.
Code :
"scripts": {
"prestart": "d2-manifest package.json manifest.webapp",
"start": "webpack-dev-server",
"test": "echo Everything probably works great\\! ## karma start test/config/karma.config.js --single-run true",
"build": "rm -rf build && set NODE_ENV=production webpack --progress && npm run manifest",
"postbuild": "cp -r src/i18n icon.png ./build/",
"validate": "npm ls --depth 0",
"manifest": "d2-manifest package.json build/manifest.webapp",
"deploy": "npm run build && mvn clean deploy",
"lint": "echo Looks good."
}
Error :
(I'm ignoring the fact that you seem to run this on a Windows machine)
The set command does not do what you think it does. To set an environment variable for a command, use
VARIABLE=value cmd
or
env VARIABLE=value cmd
This means changing
set NODE_ENV=production webpack --progress
into
env NODE_ENV=production webpack --progress
With set NODE_ENV=production webpack --progress you just set the positional parameters of the current shell instance to NODE_ENV=production, webpack and --progress.
I have a NodeJS project in Windows environment and I'm using Visual Studio and Power Shell ISE. In my package.json I have the following scripts:
"scripts": {
"start": "node ./bin/www",
"build": "del-cli public/js/app && webpack --config webpack.config.dev.js --progress --profile --watch",
"build:prod": "del-cli public/js/app && ngc -p tsconfig.aot.json && ngc -p tsconfig.aot.json && webpack --config webpack.config.prod.js --progress --profile --bail && del-cli 'public/js/app/**/*.js' 'public/js/app/**/*.js.map' '!public/js/app/bundle.js' '!public/js/app/*.chunk.js' 'assets/app/**/*.ngfactory.ts' 'assets/app/**/*.shim.ts'"
}
In the Power Shell, if I do "npm build" and then npm start, all go well and I update my server code running. But like this I need to restart all the process every time that I make a change. I saw a video that I could do "npm run build" and the process would keep running.
But when I do "npm run build" it all go well but the following:
...
building modules 541/542 modules 1 active
...er\src\animation\styles_collection.js
70% building modules 542/542 modules 0 active
12151ms building modules
At line:1 char:1
+ npm run build
+ ~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: ( ...uilding modules:String) [],
RemoteException
+ FullyQualifiedErrorId : NativeCommandError
71% sealing
...
Then it continues until the end without any more exceptions but I think this error is not allowing the building to keep running because I still need to stop the npm process and restart it. Any one who can help me on this? Thanks in advance.
The error only happen in the PowerShell, in the normal cmd it doesn't happen but I still needed to do "npm start" each time I changed the server side code. I solved that by installing and using the nodemon plugin :) .