Node: Exports field in package.json is not working - node.js

I have two repos:
my-ui-lib: a UI library imported as a dependency in package.json
my-app: a React app that imports components from my-ui-lib
I've bundled my UI library and am trying to update the package.json so that I can import the components like this:
import Button from "my-ui-lib/components/Button";
instead of
import Button from "my-ui-lib/build/components/Button";
In my my-ui-lib's package.json I have added this:
"exports": {
"./components/": "./build/components/",
"./constants/": "./build/constants/",
"./helpers/": "./build/helpers/",
"./hooks/": "./build/hooks/",
"./icons/": "./build/icons/"
},
I have also confirmed that the build folder is nested as expected when I open up node_modules inside of my-app:
▾ my-ui-lib/
▾ build/
▸ components/
▸ constants/
▸ helpers/
▸ hooks/
▸ icons/
However, I tried importing my button from just the root but it complains:
./src/App.js
Module not found: Can't resolve 'my-ui-lib/components/Button' in '/Users/edmund/Documents/src/my-app/src'
Only when I change it to import Button from "#twicapp/ui/build/components/Button"; does my page load properly.
I've tried updating the package.json file manually by:
opening up my-app/node_modules/my-ui-lib/package.json
changing up the exports field to remove slashes, periods, etc.
refreshing my my-app server
But nothing seems to work. Am I missing something?
Here's my my-ui-lib package.json:
{
"name": "my-ui-lib",
"version": "0.12.41-beta.43",
"engines": {
"node": "14.x"
},
"exports": {
"./components/": "./build/components/",
"./constants/": "./build/constants/",
"./helpers/": "./build/helpers/",
"./hooks/": "./build/hooks/",
"./icons/": "./build/icons/"
},
"files": [
"build"
],
"dependencies": {
"#ant-design/icons": "4.3.0",
"#emotion/react": "11.4.1",
"#emotion/styled": "11.3.0",
"#fullcalendar/core": "4.4.2",
"#fullcalendar/daygrid": "4.4.2",
"#fullcalendar/react": "4.4.2",
"#material-ui/core": "4.12.3",
"#material-ui/icons": "4.11.2",
"#material-ui/lab": "4.0.0-alpha.60",
"#mui/lab": "5.0.0-alpha.45",
"#mui/material": "5.0.0-rc.0",
"#tippyjs/react": "4.2.5",
"antd": "3.26.20",
"clone": "2.1.2",
"cloudinary-core": "2.11.4",
"currency-symbol-map": "5.0.1",
"date-fns": "2.23.0",
"dompurify": "2.3.3",
"final-form": "4.20.2",
"history": "5.0.1",
"lodash": "4.17.21",
"notistack": "1.0.10",
"polished": "3.7.2",
"prop-types": "15.7.2",
"react-final-form": "6.5.3",
"react-helmet": "6.1.0",
"react-hook-form": "7.15.1",
"react-progressbar": "15.4.1",
"react-text-mask": "5.4.3",
"recharts": "2.0.0-beta.8",
"styled-theme": "0.3.3"
},
"devDependencies": {
"#babel/cli": "7.15.7",
"#babel/core": "7.15.5",
"#babel/plugin-proposal-class-properties": "7.14.5",
"#babel/plugin-proposal-decorators": "7.15.4",
"#babel/plugin-proposal-do-expressions": "7.14.5",
"#babel/plugin-proposal-export-default-from": "7.14.5",
"#babel/plugin-proposal-export-namespace-from": "7.14.5",
"#babel/plugin-proposal-function-bind": "7.14.5",
"#babel/plugin-proposal-function-sent": "7.14.5",
"#babel/plugin-proposal-json-strings": "7.14.5",
"#babel/plugin-proposal-logical-assignment-operators": "7.14.5",
"#babel/plugin-proposal-nullish-coalescing-operator": "7.14.5",
"#babel/plugin-proposal-numeric-separator": "7.14.5",
"#babel/plugin-proposal-optional-chaining": "7.14.5",
"#babel/plugin-proposal-pipeline-operator": "7.15.0",
"#babel/plugin-proposal-throw-expressions": "7.14.5",
"#babel/plugin-syntax-dynamic-import": "7.8.3",
"#babel/plugin-syntax-import-meta": "7.10.4",
"#babel/preset-env": "7.15.6",
"#babel/preset-react": "7.14.5",
"#rollup/plugin-babel": "^5.3.0",
"#rollup/plugin-commonjs": "^21.0.0",
"#rollup/plugin-image": "^2.1.1",
"#rollup/plugin-json": "^4.1.0",
"#rollup/plugin-node-resolve": "^13.0.5",
"#rollup/plugin-url": "^6.1.0",
"#storybook/addon-a11y": "6.3.12",
"#storybook/addon-actions": "6.3.12",
"#storybook/addon-essentials": "6.3.12",
"#storybook/addon-knobs": "6.3.1",
"#storybook/addon-links": "6.3.12",
"#storybook/addon-postcss": "^2.0.0",
"#storybook/addon-viewport": "6.3.12",
"#storybook/addons": "6.3.12",
"#storybook/preset-create-react-app": "3.2.0",
"#storybook/react": "6.3.12",
"#storybook/storybook-deployer": "2.8.10",
"#svgr/rollup": "^5.5.0",
"#svgr/webpack": "^5.5.0",
"babel-core": "7.0.0-bridge.0",
"babel-eslint": "10.1.0",
"babel-jest": "27.2.1",
"babel-loader": "8.2.2",
"babel-plugin-styled-components": "1.13.2",
"dotenv-webpack": "^7.0.3",
"eslint": "7.32.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-import": "2.25.2",
"eslint-plugin-jest": "24.4.2",
"eslint-plugin-json": "3.1.0",
"eslint-plugin-jsx-a11y": "6.4.1",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-react": "7.26.0",
"html-webpack-plugin": "^5.4.0",
"husky": "7.0.2",
"jest": "27.2.1",
"lint-staged": "11.1.2",
"prettier": "2.4.1",
"prettier-eslint-cli": "5.0.1",
"pretty-quick": "3.1.1",
"react": "17.0.2",
"react-dom": "17.0.2",
"react-router": "5.2.1",
"react-router-dom": "5.3.0",
"rollup": "^2.58.0",
"rollup-plugin-auto-external": "^2.0.0",
"rollup-plugin-copy": "^3.4.0",
"rollup-plugin-multi-input": "^1.3.1",
"rollup-plugin-styles": "^3.14.1",
"styled-components": "5.3.1",
"webpack": "^5.58.2"
},
"peerDependencies": {
"react": "^17.0.2",
"react-dom": "^17.0.1",
"react-router": "^5.2.0",
"react-router-dom": "^5.2.0",
"styled-components": "^5.2.3"
},
"scripts": {
"start": "start-storybook -p 9009",
"test": "jest",
"build": "rollup --config",
"build-storybook": "build-storybook -o ./docs -s ./.storybook/static",
"deploy-storybook": "storybook-to-ghpages --out=docs",
"eslint": "eslint --ignore-path .gitignore ./",
"eslint:fix": "eslint --fix --ignore-path .gitignore ./",
"prettier": "prettier -c ./",
"prettier:fix": "prettier --write ./"
},
"browserslist": {
"production": [
">0.2%",
"not dead",
"not op_mini all"
],
"development": [
"last 1 chrome version",
"last 1 firefox version",
"last 1 safari version"
]
},
"lint-staged": {
"*.js": "eslint --cache --fix"
}
}

I couldn't get exports to work. This is how I worked around it. I had to change the build + publish only the dist folder

You'd better check your my-app project, make sure which build tools you use(webpack or rollup or something else?)
Build tools often offer your some fields to configure the moduleResolution strategy in their configuration file, such as webpack.config.json.
By the way, exports field of package.json will work well when you take node module resolution to import module.
For example:
set up a project like this:
tool
/-- dist
/-- add.js
/-- types
/-- index.d.ts
package.json
add.js:
module.exports.add = function(a, b) { return a + b }
index.d.ts:
/**
* add two number
*
* #example
* ```typescript
* const c = add(1, 2)
*
* // result: c === 3
* ```
*/
export declare function add(a: number, b: number): number;
package.json:
{
"name": "tool",
"exports": {
".": {
"require": "./dist",
},
"./*": {
"require":"./dist/*.js",
"types": "./types/index.d.ts"
}
}
}
in tool directory, run yarn link;
then, setup another project to import tool package, this project will be like:
practice
main.js
package.json
main.js:
const { add } = require("tool/add")
add(1, 3)
package.json:
{
"name": "practice"
}
then, in practice directory, run yarn link tool, you will see the changes:
practice
/-- node_modules
/-- tool
package.json
main.js
When you open the practice project and look at main.js in vscode, you will find that there're no type hints about add! But we have configured the types in exports field of package.json!
To your surprise , we could run main.js by node main.js, no errors no warns!
This is because when node executes the file, it will look at exports field and follow its content, but vscode type hints system don't know this and never give you a hint!
how to solve it?
Just add a jsconfig.json file under practice directory:
{
"compilerOptions": {
"moduleResolution": "Node16"
}
}
Do you get it? Yes, we adopt this format to tell vscode the moduleResolution strategy, then you could see the type hints when you hover on the add.
So, when you build your app, the build tools maybe offer you configuration field to resolve the module path. Search it!

Related

Cant run react-native app in iOS but, i upgrade my xcode to 12

When I run my app in the terminal I get this error:
error Failed to build iOS project. We ran "xcodebuild" command but it
exited with error code 65. To debug build logs further, consider
building your app with Xcode.app, by opening app.xcworkspace.
But when I try to run the app.xcworkspace I get another error:
ld: warning: directory not found for option
'-L-L/Users/josecuetosimancas/Library/Developer/Xcode/DerivedData/app-arkyvclpjmalkpagzxpefttuuars/Build/Products/Debug-iphonesimulator/BoringSSL-GRPC'
ld: library not found for -lBoringSSL-GRPC clang: error: linker
command failed with exit code 1 (use -v to see invocation)
this is my PODFILE:
require_relative '../node_modules/react-native/scripts/react_native_pods'
require_relative '../node_modules/#react-native-community/cli-platform-ios/native_modules'
platform :ios, '11.0'
target 'app' do
config = use_native_modules!
use_react_native!(:path => config["reactNativePath"])
target 'appTests' do
inherit! :complete
# Pods for testing
end
# Enables Flipper.
#
# Note that if you have use_frameworks! enabled, Flipper will not work and
# you should disable these next few lines.
use_flipper!
post_install do |installer|
flipper_post_install(installer)
end
end
target 'app-tvOS' do
# Pods for app-tvOS
target 'app-tvOSTests' do
inherit! :search_paths
# Pods for testing
end
end
and my package.json
{
"name": "app",
"version": "0.0.1",
"private": true,
"scripts": {
"start": "react-native start",
"test": "jest",
"lint": "eslint . --ext .js,.jsx,.ts,.tsx",
"ios": "react-native run-ios --simulator=\"iPhone 11 Pro Max\"",
"android": "react-native run-android",
"android:apk": "cd ./android && ./gradlew assembleRelease",
"android:aab": "cd ./android && ./gradlew bundleRelease",
"android:clean": "cd ./android && ./gradlew clean"
},
"dependencies": {
"#gorhom/bottom-sheet": "2.0.0",
"#react-native-community/blur": "^3.6.0",
"#react-native-community/checkbox": "^0.5.6",
"#react-native-community/datetimepicker": "^3.0.8",
"#react-native-community/netinfo": "^5.9.9",
"#react-native-community/picker": "^1.8.1",
"#react-native-community/viewpager": "^4.2.1",
"#react-native-firebase/app": "^9.0.0",
"#react-native-firebase/auth": "^9.3.5",
"#react-native-firebase/firestore": "^7.10.3",
"accounting": "^0.4.1",
"lodash": "^4.17.20",
"moment": "^2.29.1",
"react": "16.13.1",
"react-native": "0.63.3",
"react-native-dots-pagination": "^0.1.11",
"react-native-gesture-handler": "^1.9.0",
"react-native-navigation": "^7.3.0",
"react-native-navigation-hooks": "^6.2.0",
"react-native-progress-steps": "^1.3.4",
"react-native-reanimated": "^1.13.2",
"react-native-safe-area-context": "^3.1.9",
"react-native-safe-area-view": "^1.1.1",
"react-native-stars": "^1.2.2",
"react-native-svg": "^12.1.0",
"react-native-user-avatar": "^1.0.7",
"react-native-vector-icons": "^7.1.0"
},
"devDependencies": {
"#babel/core": "^7.8.4",
"#babel/runtime": "^7.8.4",
"#react-native-community/eslint-config": "^1.1.0",
"#types/accounting": "^0.4.1",
"#types/jest": "^25.2.3",
"#types/lodash": "^4.14.165",
"#types/moment": "^2.13.0",
"#types/react-native": "^0.63.2",
"#types/react-native-vector-icons": "^6.4.6",
"#types/react-test-renderer": "^16.9.2",
"#typescript-eslint/eslint-plugin": "^2.27.0",
"#typescript-eslint/parser": "^2.27.0",
"babel-jest": "^25.1.0",
"babel-plugin-import": "^1.13.1",
"babel-plugin-module-resolver": "^4.0.0",
"eslint": "^6.5.1",
"jest": "^25.1.0",
"metro-react-native-babel-preset": "^0.59.0",
"react-test-renderer": "16.13.1",
"typescript": "^3.8.3"
},
"jest": {
"preset": "react-native",
"moduleFileExtensions": [
"ts",
"tsx",
"js",
"jsx",
"json",
"node"
]
}
}

vue-test-utils problem with native node esm: TypeError: mount is not a function

I am using node's native esm implemenation to run tests.
Here's a minimal code example to reproduce. Either set "type":"module" in package.json or use .mjs extension for the test. node version >= 13.2.0 (otherwise >= 12.0 and experimental flag)
import {mount} from '#vue/test-utils';
// use some minimal vue component
const FooBar = import('foo-bar.vue');
const wrapper = mount(FooBar);
Throw the following error:
TypeError: mount is not a function
As reqested, this is my package.json
{
"name": "mk-vue-flex-text",
"version": "0.0.1",
"description": "My Vue component",
"main": "lib/index.js",
"license": "MIT",
"scripts": {
"build": "NODE_ENV=production webpack --mode production --config build/webpack.production.js --progress --hide-modules",
"dev": "NODE_ENV=development node server.mjs",
"github:master": "git push origin master",
"test:esm": "NODE_ENV=test node test/basic.test.mjs | tap-spec",
"test": "NODE_ENV=test node test/basic.test.js | tap-spec"
},
"browserslist": [
"last 1 version",
"> 1%",
"maintained node versions",
"not dead"
],
"devDependencies": {
"#babel/cli": "^7.7.5",
"#babel/core": "^7.7.5",
"#babel/preset-env": "^7.7.6",
"#vue/server-test-utils": "^1.0.0-beta.30",
"#vue/test-utils": "^1.0.0-beta.30",
"autoprefixer": "^9.7.3",
"babel-eslint": "^10.0.3",
"babel-loader": "^8.0.6",
"browser-env": "^3.3.0",
"css-loader": "^3.3.0",
"eslint": "^6.7.0",
"express": "^4.17.1",
"mini-css-extract-plugin": "^0.8.0",
"node-sass": "^4.13.0",
"resolve-url-loader": "^3.1.1",
"sass-loader": "^8.0.0",
"tap-spec": "^5.0.0",
"tape": "^4.11.0",
"vue": "^2.6.10",
"vue-eslint-parser": "^7.0.0",
"vue-loader": "^15.7.2",
"vue-loader-plugin": "^1.3.0",
"vue-template-compiler": "^2.6.10",
"webpack": "^4.41.2",
"webpack-dev-middleware": "^3.7.2",
"webpack-hot-middleware": "^2.25.0",
"webpack-merge": "^4.2.2"
}
}
Your FooBar import method isn't correct so it won't correctly mount, try this.
import {mount} from '#vue/test-utils';
// use some minimal vue component
import FooBar from 'foo-bar.vue';
const wrapper = mount(FooBar);

When I try to use Parcel to build a production version of a React app that works fine in development mode, I get "Cannot find module 'sass'"

I've built a simple React/Redux app and am using Parcel for the bundler. It works fine in development mode, that is, using the script
"dev": "parcel ./src/index.html",
but when I tried to do
"build": "parcel build ./src/index.html",
I got the following error
/Users/abc/Documents/Projects/sandbox/smart/src/styles/main.scss: Cannot find module 'sass' from '/Users/abc/Documents/Projects/sandbox/smart/src/styles'
at /Users/abc/Documents/Projects/sandbox/smart/node_modules/resolve/lib/async.js:97:35
at processDirs (/Users/abc/Documents/Projects/sandbox/smart/node_modules/resolve/lib/async.js:244:39)
at isdir (/Users/abc/Documents/Projects/sandbox/smart/node_modules/resolve/lib/async.js:251:32)
at /Users/abc/Documents/Projects/sandbox/smart/node_modules/resolve/lib/async.js:23:69
at FSReqWrap.oncomplete (fs.js:152:21)
This is the first time I've tried to build an app using Parcel and I'm lost. I'm using node-sass to import my sass files directly -- perhaps this has something to do with that.
The referenced file (main.scss) is referenced in App.js like this
import "../../styles/main.scss";
and is the first sass file to be included (App is loaded into the DOM like this in index.js:
const store = configureStore()
ReactDOM.render(
<Provider store={store}>
<App />
</Provider>,
document.getElementById("root")
)
This is running under Node 11.15. My package.json follows -- any hints or help much appreciated!
{
"name": "friender",
"version": "1.0.0",
"description": "",
"main": "index.js",
"jest": {
"setupFiles": ["jest-localstorage-mock"]
},
"scripts": {
"dev": "parcel ./src/index.html",
"build": "parcel build ./src/index.html",
"lint": "eslint \"src/**/*.{js,jsx}\" --quiet",
"test": "jest"
},
"prettier": {
"semi": false
},
"keywords": [],
"author": "",
"license": "MIT",
"devDependencies": {
"#babel/cli": "^7.6.0",
"#babel/core": "^7.6.0",
"#babel/plugin-transform-runtime": "^7.5.5",
"#babel/preset-env": "^7.6.0",
"#types/jest": "^24.0.18",
"babel-eslint": "^10.0.3",
"babel-preset-react": "^7.0.0-beta.3",
"eslint": "^6.2.2",
"eslint-config-prettier": "^6.1.0",
"jest": "^24.9.0",
"jest-localstorage-mock": "^2.4.0",
"parcel-bundler": "^1.12.3",
"prettier": "^1.18.2"
},
"dependencies": {
"#emotion/babel-preset-css-prop": "^10.0.14",
"#emotion/core": "^10.0.16",
"#emotion/styled": "^10.0.15",
"#fortawesome/fontawesome-svg-core": "^1.2.0-7",
"#fortawesome/free-solid-svg-icons": "^5.11.1",
"#fortawesome/react-fontawesome": "^0.1.4",
"axios": "^0.19.0",
"bulma": "^0.7.5",
"eslint-plugin-jest": "^22.17.0",
"eslint-plugin-react": "^7.14.3",
"immer": "^4.0.0",
"node-sass": "^4.12.0",
"prop-types": "^15.7.2",
"react": "16.x",
"react-detect-offline": "^2.4.0",
"react-dom": "^16.9.0",
"react-fontawesome": "^1.6.1",
"react-modal": "^3.10.1",
"react-redux": "^7.1.1",
"redux": "^4.0.4",
"redux-devtools-extension": "^2.13.8",
"redux-thunk": "^2.3.0"
}
}
Try instead per the documentation for SCSS and error Cannot find module 'sass' use module sass instead of node-sass:
npm install -D sass
The documentation mentions being able to use node-sass, but there are several active issues with node-sass. Module sass may help resolve the error and allow you use SCSS in your application.
Hopefully that helps!

Requiring external babel register error during npm start

I started angular Application via npm start with gulp/babel enabled.
After starting, the browser page keeps loading and is throwing an error "requiring external babel register".
given below logs from terminal:
[19:52:47] Requiring external module #babel/register
[19:52:53] Using gulpfile ~\WebstormProjects\agent-dealer-portal-frontend\portals-integration\front\gulpfile.babel.js
[19:52:53] Starting 'default'...
babel-register is listed properly in the terminal.
C:\Users\vramanathan\WebstormProjects\agent-dealer-portal-frontend\portals-integration\front>npm list babel-register
#globant/cna_national_portal#0.35.0 C:\Users\vramanathan\WebstormProjects\agent-dealer-portal-frontend\portals-integration\front
`-- babel-cli#6.26.0
+-- babel-core#6.26.3
| `-- babel-register#6.26.0 deduped
`-- babel-register#6.26.0
.babelrc file contents:
{
"presets": [
"es2015"
]
}
Package.json:
{
"main": "gulpfile.babel.js",
"name": "#globant/cna_national_portal",
"version": "00.35.00",
"babel": {
"presets": [
"#babel/env"
],
"compact": false
},
......
"devDependencies": {
"#babel/core": "^7.5.5",
"#babel/preset-env": "^7.5.5",
"#babel/register": "^7.5.5",
"babel-cli": "^6.26.0",
"babel-preset-es2015": "^6.18.0",
"del": "^3.0.0",
"eslint": "^5.0.1",
"gulp": "^4.0.2",
"gulp-autoprefixer": "^3.1.1",
"gulp-babel": "^6.1.2",
"gulp-cli": "^1.4.0",
"gulp-concat": "^2.6.1",
"gulp-cssnano": "^2.1.2",
"gulp-eslint": "^4.0.2",
"gulp-header": "^1.8.9",
"gulp-if": "^2.0.2",
"gulp-imagemin": "^2.4.0",
"gulp-load-plugins": "^1.4.0",
"gulp-ng-annotate": "^2.0.0",
"gulp-rev": "^8.1.1",
"gulp-rev-replace": "^0.4.4",
"gulp-sass": "^3.1.0",
"gulp-sass-glob": "^1.0.8",
"gulp-sourcemaps": "^1.11.0",
"gulp-uglify": "^1.5.4",
"gulp-uncss": "^1.0.6",
},
"private": true,
"scripts": {
"start": "gulp",
"build": "gulp build --production",
"test": "gulp test",
"test:watch": "gulp test:watch",
"eslint": "gulp eslint"
}
}
The following may be useful: there is some incompatibilities between certain versions of Node / gulp when that arise when using different OSs (I'm on Chromebook for my work).
For me, downgrading to Node 10 solved my issue (via command): nvm use 10

Cant resolve fbjs/lib/memoizeStringOnly

Just did a refresh of my computer but now Im having trouble running my code....
When running "npm start" I get the following error:
> ERROR in ./~/react-dom/lib/CSSPropertyOperations.js Module not found:
> Error: Can't resolve 'fbjs/lib/memoi zeStringOnly' in
> 'C:\Code\Project.Web\node_modules\react-dom\lib'
> # ./~/react-dom/lib/CSSPropertyOperations.js 20:24-61
> # ./~/react-dom/lib/ReactDOMComponent.js #
> ./~/react-dom/lib/ReactDefaultInjection.js #
> ./~/react-dom/lib/ReactDOM.js # ./~/react-dom/index.js #
> ./source/components/index.js # multi
> (webpack)-dev-server/client?http://0.0.0.0:30 00
> webpack/hot/dev-server ./index.js
I tried to update all packages but got same error...
Here is my package.json file:
{
"name": "homecore.web",
"version": "1.0.0",
"description": "",
"main": "index.js",
"scripts": {
"test": "echo \"Error: no test specified\" && exit 1",
"start": "webpack-dashboard -t 'HomeCore' -- webpack-dev-server --colors --no-info",
"build": "rm -rf ./build && NODE_ENV=\"production\" webpack",
"lint-break-on-errors": "eslint ./source/js ./webpack.config.js -f table --ext .js --ext .jsx",
"lint": "eslint ./source/js ./webpack.config.js -f table --ext .js --ext .jsx || true",
"preview": "NODE_ENV=\"production\" webpack-dashboard -t 'Preview Mode - React-Redux Boilerplate' -- webpack-dev-server",
"hook-add": "prepush install",
"hook-remove": "prepush remove"
},
"author": "",
"license": "ISC",
"devDependencies": {
"autoprefixer": "^6.7.7",
"babel-core": "^6.24.1",
"babel-eslint": "^7.2.3",
"babel-loader": "^7.0.0",
"babel-plugin-syntax-decorators": "^6.13.0",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-runtime": "^6.23.0",
"babel-preset-es2015": "^6.24.1",
"babel-preset-react": "^6.24.1",
"babel-preset-react-hmre": "^1.1.1",
"babel-preset-stage-0": "^6.24.1",
"babel-runtime": "^6.23.0",
"css-loader": "0.28.1",
"eslint": "^3.19.0",
"eslint-config-airbnb": "^14.1.0",
"eslint-plugin-import": "^2.2.0",
"eslint-plugin-jsx-a11y": "^4.0.0",
"eslint-plugin-react": "^6.10.3",
"extract-text-webpack-plugin": "^2.1.0",
"file-loader": "^0.11.1",
"html-webpack-plugin": "^2.28.0",
"less": "^2.7.2",
"less-loader": "^4.0.3",
"postcss-loader": "^1.3.3",
"prepush": "^3.1.11",
"style-loader": "^0.17.0",
"url-loader": "^0.5.8",
"webpack": "^2.4.1",
"webpack-dashboard": "^0.4.0",
"webpack-dev-server": "^2.4.5"
},
"dependencies": {
"alt": "0.18.6",
"alt-utils": "^1.0.0",
"babel-polyfill": "^6.23.0",
"es6-promise": "^4.1.0",
"immutable": "^3.8.1",
"isomorphic-fetch": "^2.2.1",
"react": "^15.5.4",
"react-dom": "^15.5.4",
"react-router": "^4.1.1",
"react-router-dom": "^4.1.1",
"semantic-ui-react": "^0.68.2",
"whatwg-fetch": "^2.0.3"
},
"prepush": [
"npm run lint-break-on-errors --silent"
]
}
Ok so after a lot of googleing, I found a work around. Im still not sure why i get this error.
But according to this post there is a way to add alias in webpack.
So i added this to my webpack.config.js
var alias = {};
alias['fbjs/lib/memoizeStringOnly'] = '../node_modules/fbjs/lib/memoizeStringOnly';
module.exports = {
.
.
alias : alias,
.
.
}
and now it works!
But, and now Im guessing, some package must be broken trying to access this component from the wrong location
Within the last week or so, I've run into the same issue but with react-dom#15.4.2 instead of react-dom#15.5.4. What I think I've found to be the issue is that Webpack isn't able to resolve the fbjs dependency within the react-dom/node_modules directory.
For me, I was able to solve the issue by including the fbjs package as an explicit dependency in the package.json. Now instead of the project-level dependency linking to the peer of react-dom, the module in react-dom links to the project-level module.
Now, I don't think this is necessarily the right solution, especially if you allow minor version bumps with '~' and '^' in your package.json, but because we are only updating our dependencies when we need to by hand, our team is comfortable specifying the version of fbjs.
Snippet of our package.json:
"dependencies": {
"assets-webpack-plugin": "3.5.1",
"babel-core": "6.24.0",
"babel-loader": "6.4.1",
"babel-preset-es2015": "6.24.0",
"babel-preset-react": "6.23.0",
"css-loader": "0.26.4",
"del": "2.2.2",
"es6-promise": "4.1.0",
"fbjs": "0.8.12",
"file-loader": "0.10.1",
"flux": "2.1.1",
"highcharts": "5.0.10",
"imports-loader": "0.7.1",
"jquery": "2.1.3",
"keymirror": "0.1.1",
"lodash": "3.10.1",
"lodash.clonedeep": "4.5.0",
"material-design-icons": "2.2.3",
"material-ui": "0.17.1",
"moment": "2.18.1",
"object-assign": "4.1.1",
"postcss-loader": "1.3.3",
"rc-progress": "2.1.0",
"react": "15.4.2",
"react-addons-perf": "15.4.2",
"react-data-grid": "1.0.85",
"react-dom": "15.4.2",
"react-highcharts": "11.5.0",
"react-router": "3.0.3",
"react-tap-event-plugin": "2.0.1",
"sass-loader": "6.0.3",
"style-loader": "0.13.2",
"superagent": "3.5.2",
"underscore": "1.8.3",
"url-loader": "0.5.8",
"webpack": "2.4.1"
},
I ran into this error as well after uninstalling a package. It seems fbjs was somehow removed as well, even though other packages still depended on it.
I fixed it by manually installing fbjs with npm install fbjs --save

Resources