1

I have a Rails app and something recently changed in such a way that the rails server will start but when I load a page I get an NPM related error in the browser console. I did not set up NPM/VueJS in this app so need some help getting it running locally...

Error: Module build failed (from ./node_modules/babel-loader/lib/index.js):
Error [ERR_PACKAGE_PATH_NOT_EXPORTED]: No "exports" main resolved in /Users/meltemi/rails/myapp/node_modules/@babel/helper-compilation-targets/package.json
    at applyExports (internal/modules/cjs/loader.js:524:9)
    at resolveExports (internal/modules/cjs/loader.js:541:12)
    at Function.Module._findPath (internal/modules/cjs/loader.js:661:22)
    at Function.Module._resolveFilename (internal/modules/cjs/loader.js:963:27)
    at Function.Module._load (internal/modules/cjs/loader.js:859:27)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/Users/meltemi/rails/myapp/node_modules/@babel/preset-env/lib/debug.js:8:33)
    at Module._compile (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at Object.<anonymous> (/Users/meltemi/rails/myapp/node_modules/@babel/preset-env/lib/index.js:11:14)
    at Module._compile (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:192:30)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1167:10)
    at Module.load (internal/modules/cjs/loader.js:996:32)
    at Function.Module._load (internal/modules/cjs/loader.js:896:14)
    at Module.require (internal/modules/cjs/loader.js:1036:19)
    at require (/Users/meltemi/rails/myapp/node_modules/v8-compile-cache/v8-compile-cache.js:161:20)
    at requireModule (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/files/plugins.js:165:12)
    at loadPreset (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/files/plugins.js:83:17)
    at createDescriptor (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:154:9)
    at /Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:109:50
    at Array.map (<anonymous>)
    at createDescriptors (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:109:29)
    at createPresetDescriptors (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:101:10)
    at presets (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-descriptors.js:47:19)
    at mergeChainOpts (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-chain.js:320:26)
    at /Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-chain.js:283:7
    at Generator.next (<anonymous>)
    at buildRootChain (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/config-chain.js:90:27)
    at buildRootChain.next (<anonymous>)
    at loadPrivatePartialConfig (/Users/meltemi/rails/myapp/node_modules/@babel/core/lib/config/partial.js:95:62)
    at loadPrivatePartialConfig.next (<anonymous>)

This is similar to an issue reported recently in this SO post but in that case NPM wasn't embedded in a Rails app. Regardless I tried their solution by removing node_modules (there is no package-lock.json) and running npm install but that led to more errors in the shell:

$ npm install
npm WARN deprecated [email protected]: 'postcss-cssnext' has been deprecated in favor of 'postcss-preset-env'. Read more at https://moox.io/blog/deprecating-cssnext/
npm WARN deprecated [email protected]: Legacy versions of mkdirp are no longer supported. Please update to mkdirp 1.x. (Note that the API surface has changed to use Promises in 1.x.)
npm WARN deprecated [email protected]: request has been deprecated, see https://github.com/request/request/issues/3142
npm WARN deprecated [email protected]: You can find the new Popper v2 at @popperjs/core, this package is dedicated to the legacy v1
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm WARN deprecated [email protected]: core-js@<3 is no longer maintained and not recommended for usage due to the number of issues. Please, upgrade your dependencies to the actual version of core-js@3.
npm WARN deprecated [email protected]: Browserslist 2 could fail on reading Browserslist >3.0 config used in other tools.
npm ERR! code 1
npm ERR! Command failed: git checkout ^2.4.0
npm ERR! error: pathspec '^2.4.0' did not match any file(s) known to git
npm ERR!

This app is working in production so I'm not interested in updating outdated libraries at the moment. I'm not an NPM/JS guru so would appreciate any advice no matter how rudimentary this probably is. Thanks!

Edit: Results of yarn install --check-files as per request

$ yarn install --check-files
yarn install v1.22.4
[1/5] 🔍  Validating package.json...
[2/5] 🔍  Resolving packages...
[3/5] 🚚  Fetching packages...
[4/5] 🔗  Linking dependencies...
[5/5] 🔨  Building fresh packages...
$ node -e "try { require('fs').symlinkSync('../../node_modules/@bower_components', 'vendor/assets/components', 'junction') } catch (e) { }"
✨  Done in 10.22s.
2
  • Are you using Linux or Mac? Commented Apr 14, 2020 at 3:49
  • MacOS (10.15.4) Commented Apr 14, 2020 at 4:05

2 Answers 2

0

Are you using yarn on your project? If so try:

yarn install --check-files

And please post the result of your terminal.

Sign up to request clarification or add additional context in comments.

2 Comments

Results of yarn install --check-files above. Also tried removing the node_modules folder and running yarn install again…to no avail.
Removing node_modules is not sufficient, also need to remove yarn.lock
0

this my case , just remove node_modules and package-lock.json and run npm installso npm run build working correctly.show here for this answer

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.