添加链接
link管理
链接快照平台
  • 输入网页链接,自动生成快照
  • 标签化管理网页链接

Hello!

I’ma fairly long-term paid user of render, but first time running into this issue.

When trying to deploy my front-end app, I’m getting the error:

Module not found: Error: You attempted to import /opt/render/project/src/node_modules/crypto-browserify/index.js which falls outside of the project src/ directory. Relative imports outside of src/ are not supported.
Jun 11 08:21:31 PM  You can either move it inside src/, or add a symlink to it from project's node_modules/.

This is an excerpt from my config-overrides.js file:

Object.assign(fallback, {
    crypto: require.resolve("crypto-browserify"),
    stream: require.resolve("stream-browserify"),
    assert: require.resolve("assert"),
    http: require.resolve("stream-http"),
    https: require.resolve("https-browserify"),
    os: require.resolve("os-browserify"),
    url: require.resolve("url"),

I need to use the crypto library, which is no longer autoincluded in CRA. I followed the react-app-rewired instructions to override this dependency, and instead use crypto-browserify , but then this error shows up. Note that I don’t get this error when deploying locally, only after trying to deploy from Render. My issue is basically the same as this person’s:

https://stackoverflow.com/questions/76057482/react-polyfills-react-app-rewired-making-crypto-crypto-browserify-get-imported

Does anyone here have any experience with this, and/or how to get around it?

Thanks and Best,

Hi Rob,

The first thing I recommend checking is that the versions you are using locally match the versions being used on Render. Next, it would be helpful to see your build command so I can check if anything jumps out at me as an issue. Then we can go from there.

Regards,

Render Support Engineer, MT (UTC-6)

Hi Mike,

Appreciate your prompt response. You say,

"The first thing I recommend checking is that the versions you are using locally match the versions being used on Render. "

So… how exactly would I check this? Does this indicate that Render would have its own version of these polyfill libraries stored somewhere that it accesses on app launch (i.e. crypto-browserify, stream-browserify, etc)? They are properly logged in my package.json file.

As for my build command, here it is:

npm install react-scripts && npm install && npm run build && react-app-rewired build

Any other info you might need, please let me know!

Thanks,

Hi Rob,

Regarding version checking, it is just about making sure the versions you are using locally, whether particular libraries or the framework itself, match what your Render service is running. Sometimes Render will pick default versions of frameworks (like Node) and related tools that are different than what people might be running on their local machines to develop.

As an example, your local environment might be using a different version of Node than the default version chosen by your Render service. This issue can be avoided by following our docs and, in this example, explicitly setting the NODE_VERSION environment variable in your service so that it matches the version you are working on locally.

Once we can rule out version mismatch issues we can begin looking at other causes for the error.

Regards,

Render Support Engineer, MT (UTC-6)