I've always used just npm and never yarn/webpack explicitly. I need to run the code from this repo: https://github.com/looker-open-source/custom_visualizations_v2
Like a dev server or something to ensure it's serving the files properly but I don't see a "run" like npm run start
. Does this just not exist with yarn? It feels like this code should work as is and I shouldn't have to add anything.
EDIT: I've now tried yarn run watch
but it just seems to build the code again and not actually host anywhere
CodePudding user response:
npm run somecommand
just looks up in the "scripts"
field of package.json
for the key
somecommand
and executes the value in the terminal.
So npm run start
basically runs the start
script from package.json
The same thing is done using yarn
via simply yarn start
In the linked repo, there isn't a start
script in the package.json
, rather a watch
script, so you should be able to run it with the below steps:
yarn
to install dependencies after cloning the repo to local (similar tonpm install
)yarn watch
to start the webpack server (analogous tonpm run watch
)
Edit:
Turns out the watch
command is just setting up webpack to watch for changes and recompile the project every time there is a change.
To run a development server, you will need to add another script preferably with name start
and use webpack-dev-server
So the package.json
has entries like:
...
"watch": "webpack --config webpack.config.js --watch --progress",
"start": "webpack-dev-server --config webpack.config.js",
...
Then running yarn start
should open a dev server at localhost:8080