I am trying to follow this tutorial on https://storybook.js.org/tutorials/intro-to-storybook/react/en/get-started/
The commands that are given in the tutorial are as follows
# Clone the template
npx degit chromaui/intro-storybook-react-template taskbox
cd taskbox
# Install dependencies
yarn
# Run the test runner (Jest) in a terminal:
yarn test --watchAll
# Start the component explorer on port 6006:
yarn storybook
# Run the frontend app proper on port 3000:
yarn start
I am however running into an issue when yarn storybook on my wsl2 ubuntu terminal.
Here is the error
yarn storybook
yarn run v1.22.5
warning ../package.json: No license field
$ start-storybook -p 6006 -s public
info #storybook/react v6.3.0
info
info => Loading presets
info => Serving static files from ./public at /
info => Loading 1 config file in "/mnt/d/taskbox/.storybook"
info => Loading 9 other files in "/mnt/d/taskbox/.storybook"
info => Adding stories defined in "/mnt/d/taskbox/.storybook/main.js"
info => Using prebuilt manager
info => Loading Webpack configuration from `node_modules/react-scripts`
info => Removing existing JavaScript and TypeScript rules.
info => Modifying Create React App rules.
info => Using default Webpack4 setup
(node:7126) [DEP0148] DeprecationWarning: Use of deprecated folder mapping "./" in the "exports" field module resolution of the package at /mnt/d/taskbox/node_modules/postcss-safe-parser/node_modules/postcss/package.json.
Update this package.json to use a subpath pattern like "./*".
(Use `node --trace-deprecation ...` to show where the warning was created)
17% building 63/88 modules 25 active /mnt/d/taskbox/node_modules/global/window.jsBrowserslist: 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
webpack built preview 0ef1297f848efab9f24c in 139265ms
╭─────────────────────────────────────────────────────╮
│ │
│ Storybook 6.3.0 started │
│ 3.97 min for preview │
│ │
│ Local: http://localhost:6006/ │
│ On your network: http://172.22.229.210:6006/ │
│ │
│ A new version (6.3.6) is available! │
│ │
│ Upgrade now: npx sb#latest upgrade │
│ │
│ Read full changelog: https://git.io/fhFYe │
│ │
╰─────────────────────────────────────────────────────╯
node:internal/errors:456
ErrorCaptureStackTrace(err);
^
Error: spawn wslvar ENOENT
at Process.ChildProcess._handle.onexit (node:internal/child_process:282:19)
at onErrorNT (node:internal/child_process:480:16)
at processTicksAndRejections (node:internal/process/task_queues:83:21) {
errno: -2,
code: 'ENOENT',
syscall: 'spawn wslvar',
path: 'wslvar',
spawnargs: [ 'systemroot' ],
cmd: 'wslvar systemroot',
stdout: '',
stderr: ''
}
error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
I've been having a hard time finding similar errors to go off of since it seems like a rare error. I suspect it's related to me running storybook on WSL2 though.
According to this Github comment, the error is usually caused by either:
powershell.exe not being in the path (unlikely, but could be the case if a /etc/wsl.conf explicitly disabled Windows PATH interop).
Missing wslvar, which is part of the wslu (WSL Utilities) package. While it's installed by default in some WSL distributions, it may not be up-to-date or installed in some. See the Github page for installation instructions for each distribution.
Related
I have a react.js project and have just gotten started with testing. I installed the react-testing-library and jest to get started with it.
However, when I run
npm test
I get the following error.
/Users/Tomascdmota/Downloads/Trust-Motores-main/node_modules/react-scripts/node_modules/jest-cli/build/cli/index.js:40
execute(argv, argv.projects, result => {
^
TypeError: execute is not a function
at Object.run (/Users/Tomascdmota/Downloads/Trust-Motores-main/node_modules/react-scripts/node_modules/jest-cli/build/cli/index.js:40:3)
at Object.<anonymous> (/Users/Tomascdmota/Downloads/Trust-Motores-main/node_modules/react-scripts/scripts/test.js:104:6)
at Module._compile (node:internal/modules/cjs/loader:1091:14)
at Object.Module._extensions..js (node:internal/modules/cjs/loader:1120:10)
at Module.load (node:internal/modules/cjs/loader:971:32)
at Function.Module._load (node:internal/modules/cjs/loader:812:14)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:76:12)
at node:internal/main/run_main_module:17:47
My jest version is 26.6.0
I haven't added anything.
I have deleted the node_modules, package-lock.json, yarn.lock and removed jest from the dependencies/DevDependencies. After that I ran yarn install.
I still get that same error. I have googled the error and looked it up here on SO but came short-handed.
Any helps is appreciated.
I have deleted the node_modules, package-lock.json, yarn.lock
If you had package-lock.json and yarn.lock files at the same time, it looks like at some point you probably used both yarn and npm to install packages, which can definitely cause conflicts.
In terms of this specific issue, I ran into the exact same problem and it was due to a package conflict with jest-cli. The solution in my case was to upgrade react-scripts, e.g. (pick one):
Yarn
yarn add react-scripts
Or NPM
npm i react-scripts#latest
Details
In case it helps, here are more details on my specific issue and how I resolved it. I got the same error and it looks like I had two different versions of jest-cli installed:
$ npm list jest-cli
├─┬ jest-enzyme#4.2.0
│ └─┬ jest#27.5.1
│ └── jest-cli#27.5.1
└─┬ react-scripts#1.1.0
└─┬ jest#20.0.4
└── jest-cli#20.0.4
In my case, the solution was to upgrade react-scripts:
npm i react-scripts#latest
It looks like the dependency conflict is now resolved:
$ npm list jest-cli
└─┬ jest-enzyme#4.1.1
└─┬ jest#27.5.1
└── jest-cli#27.5.1
In fact, it doesn't even show jest-cli as a dependency of react-scripts any more, because it's using the same version of jest as jest-enzyme now:
$ npm list jest
├─┬ jest-enzyme#4.1.1
│ └── jest#27.5.1
└─┬ react-scripts#5.0.0
├─┬ jest-watch-typeahead#1.0.0
│ └── jest#27.5.1 deduped
└── jest#27.5.1 deduped
So far I have build the image and deployed it to AWS EC2. But I want to use
serve -s build
to serve the app in production mode.
I did it locally and apparently everything seems to be fine..I get this..
┌──────────────────────────────────────────────────┐
│ │
│ Serving! │
│ │
│ - Local: http://localhost:5000 │
│ - On Your Network: http://192.168.1.91:5000 │
│ │
│ Copied local address to clipboard! │
│ │
└──────────────────────────────────────────────────┘
And the page enters..but the when I try to make a request to the api I get 404.
I wanted to know how does react build works and what do I need to do to put it in production mode. And also, what is the dist folder for?
This is my Dockerfile:
FROM node
#Create app directory
WORKDIR /app
# A wildcard is used to ensure both package.json AND package-lock.json are copied
# where available (npm#5+)
COPY package*.json ./
#Install dependencies
RUN npm install
RUN npm install react-scripts#3.4.1 -g --silent
#Copy app's source code inside the Docker image
COPY . .
#Expose the app's port
EXPOSE 3000
#Run the app when the container is ran
CMD ["npm", "start""]
Thanks!
This is my Dockerfile I use when I run it with serve -s build
# pull official base image
FROM node:13.12.0-alpine
# set working directory
WORKDIR /app
# Copies package.json and package-lock.json to Docker environment
COPY package*.json ./
# Installs all node packages
RUN npm install
# Copies everything over to Docker environment
COPY . .
# Build for production.
RUN npm run build --production
# Install `serve` to run the application.
RUN npm install -g serve
# Uses port which is used by the actual application
EXPOSE 5000
# Run application
#CMD [ "npm", "start" ]
CMD serve -s build
I just switch between npm start (debug) and serve (for production).
Im create new a react-native project
react-native init navigationApp--version 0.59.8
But have build problems... When i try run (react-native run-android)
Console stay step: app:installDebug and have some errors in npm part.
I tried they step-step;
1.rm -rf node_modules package-lock.json
2.npm install react-native#0.55.2 babel-preset-react-native#4.0.0
3.npm install
4.react-native run-android
λ react-native run-android
Scanning folders for symlinks in C:\Users\MONSTER\Desktop\project\react-navigation\navigationApp\node_modules (55ms)
JS server already running.
Building and installing the app on the device (cd android && gradlew.bat installDebug)...
Starting a Gradle Daemon (subsequent builds will be faster)
<============-> 97% EXECUT¦NG [7m 40s]
IDLE
IDLE
IDLE
IDLE
IDLE
:app:installDebug
IDLE
IDLE
λ npm start
> navigationApp#0.0.1 start C:\Users\MONSTER\Desktop\project\react-navigation\navigationApp
> node node_modules/react-native/local-cli/cli.js start
Scanning folders for symlinks in C:\Users\MONSTER\Desktop\project\react-navigation\navigationApp\node_modules (49ms)
┌───────────────────────────────────────────────────────────────────────────
───┐
│
│
│ Running Metro Bundler on port 8081.
│
│
│
│ Keep Metro running while developing on any JS projects. Feel free to
│
│ close this tab and run your own Metro instance if you prefer.
│
│
│
│ https://github.com/facebook/react-native
│
│
│
└───────────────────────────────────────────────────────────────────────────
───┘
Looking for JS files in
C:\Users\MONSTER\Desktop\project\react-navigation\navigationApp
Metro Bundler ready.
Loading dependency graph, done.
ERROR EPERM: operation not permitted, lstat 'C:\Users\MONSTER\Desktop\project\react-navigation\navigationApp\android\app\build\intermediates\blame\res\debug\multi-v2'
npm ERR! code ELIFECYCLE
npm ERR! errno 11
npm ERR! navigationApp#0.0.1 start: `node node_modules/react-native/local-cli/cli.js start`
npm ERR! Exit status 11
npm ERR!
npm ERR! Failed at the navigationApp#0.0.1 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! C:\Users\MONSTER\AppData\Roaming\npm-cache\_logs\2019-07-31T07_51_31_477Z-debug.log
ERROR IMAGE
CMD IMAGE
you must clean your project as below
npm start -- --reset-cache
react-native run-android
Also, you can clear project android gradlew file,
cd/android
./gradlew clean
I try to run a REACT application on bluemix / IBMCloud which runs successful on my local workstation.
I get the error Module not found: Can't resolve 'watson-react-components'
when I invoke the application (deploy to bluemix is successful)
Here the import statement im my java script code
import React from 'react';
import './Conversation.css';
import { InputWithButton } from 'watson-react-components';
import Message from './Message.js';
I install the packagethe following install commands
# Install & build
npm install && npm install watson-react-components && npm run build
this is what I get during the installation of the packages
│ └── whatwg-fetch#2.0.3
└─┬ watson-react-components#0.6.16
├── map-range#0.1.2
├── numeral#2.0.6
├─┬ prismjs#1.11.0
│ └─┬ clipboard#1.7.1
│ ├─┬ good-listener#1.2.2
│ │ └── delegate#3.2.0
│ ├── select#1.1.2
│ └── tiny-emitter#2.0.2
Here the error message on the app
Failed to compile
./src/Conversation.js
Module not found: Can't resolve 'watson-react-components' in '/home/vcap/app/src'
sorry sorry --- the problem was sitting in front of the computer. I missed the cf push command in the deployment script.
Problem solved!!! sorry again
The bug is in the command to install the app.
It should be npm install && npm install --save watson-react-components && npm run build
You forgot a --save
There is small React/Redux app I'd like to check against nsp check.
For instance, nsp complains that debug 2.6.8 package I use in app contains a vulnerability. So I need to bump version of debug:
Regular Expression Denial of Service
│ Name │ debug
│ CVSS │ 3.7 (Low)
│ Installed │ 2.6.8
│ Vulnerable │ <= 2.6.8 || >= 3.0.0 <= 3.0.1
│ Patched │ >= 2.6.9 < 3.0.0 || >= 3.1.0
│ Path │ sms-web#0.0.1 > webpack-dev-server#2.5.0 >
compression#1.7.0 >
│ │ debug#2.6.8
│ More Info │ https://nodesecurity.io/advisories/534
I tried npm update --depth=7, but it didn't update debug package.
So how can I update deeply placed packages, e.g. debug?
According to the docs:
As of npm#2.6.1, the npm update will only inspect top-level packages. Prior versions of npm would also recursively inspect all dependencies. To get the old behavior, use npm --depth 9999 update. In order to update just the debug package you could do
npm --depth 9999 update debug
or else you could just uninstall and reinstall it like
npm uninstall -S debug
npm install -S debug