question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

operation not permitted

See original GitHub issue

Verify canary release

  • I verified that the issue exists in the latest Next.js canary release

Provide environment information

Operating System:
  Platform: win32
  Arch: x64
  Version: Windows 10 Pro
Binaries:
  Node: 16.15.0
  npm: N/A
  Yarn: N/A
  pnpm: N/A
Relevant packages:
  next: 12.3.2-canary.0
  eslint-config-next: 12.3.1
  react: 18.2.0
  react-dom: 18.2.0

What browser are you using? (if relevant)

No response

How are you deploying your application? (if relevant)

No response

Describe the Bug

When I run the build I have this error

> Build error occurred
[Error: EPERM: operation not permitted, scandir 'C:\Users\axell\Documents\Development\pikas-template\apps\app\.next\standalone\apps\app\node_modules\next'] {
  errno: -4048,
  code: 'EPERM',
  syscall: 'scandir',
  path: 'C:\\Users\\axell\\Documents\\Development\\pikas-template\\apps\\app\\.next\\standalone\\apps\\app\\node_modules\\next'
}

And in my next.config.js I have this

require('dotenv-flow').config({ path: '../..' });

const withPWA = require('next-pwa');
const withPlugins = require('next-compose-plugins');
const withBundleAnalyzer = require('@next/bundle-analyzer')({
  enabled: process.env.ANALYZE === 'true',
});
const { join } = require('path');
const withTM = require('next-transpile-modules')([]);

const plugins = [withTM, withBundleAnalyzer, withPWA];

/**
 * @type {import('next').NextConfig}
 */
const nextConfig = {
  swcMinify: true,
  reactStrictMode: true,
  output: 'standalone',
  experimental: {
    outputFileTracingRoot: join(__dirname, '../../'),
  },
  i18n: {
    locales: ['en', 'fr'],
    defaultLocale: 'en',
  },
  pwa: {
    disable: process.env.NODE_ENV === 'development',
    dest: 'public',
  },
};

module.exports = withPlugins(plugins, nextConfig);

I found these issues that talk about it too: #36645 #1537

Expected Behavior

I just want to build my app

Link to reproduction

https://github.com/Achaak/pikas-template

To Reproduce

Use this command

pnpm i

pnpm generate

pnpm build:packages

cd apps/app

pnpm build  <-- The bug appears here

Issue Analytics

  • State:open
  • Created a year ago
  • Reactions:7
  • Comments:6 (1 by maintainers)

github_iconTop GitHub Comments

2reactions
j2ghzcommented, Sep 28, 2022

Unfortunately, I cannot reproduce the issue myself, but it looks related to the output: "standalone" or outputFileTracingRoot settings.

To investigate further, here are some things we could try:

  • Build with and without output: "standalone".

  • Check if it builds when outputFileTracingRoot is not utilized

  • Check a different package manager. yarn or npm, to see if the issue is pnpm-specific or not.

  • It would also be nice to see if we can pinpoint exactly which version of next this bug was introduced in. (A good candidate to start bisecting is v12.1.7-canary.48, when output: "standalone" was stabilized. If the issue reproduces still, the bug might have always existed.)

  • output: standalone is enough to break it, without it it works
  • other package managers: npm works, yarn works
  • next 12.1.7-canary.48 produces the same error, so I think it’s always been there

This is my minimal reproduction example, it’s basically just 3 steps (powershell):

# Make dir if not exists
mkdir -Force "./next-40760-repro"
# cd to it
pushd "./next-40760-repro"
# delete any content from previous run
rm * -Recurse -Force 

# create-next-app with pnpm
pnpm create next-app --ts --use-pnpm .

# add output: 'standalone' to next.config.js
[regex]$pattern = ",\s+}"
$pattern.Replace((cat "next.config.js"), ",output: 'standalone',};", 1) | Set-Content "next.config.js"

# build
pnpm next build

popd
0reactions
drewbittcommented, Dec 13, 2022

I have just tried it in Linux and it works perfectly. So is Windows + pnpm specific. Turbotrace on Windows does not fix the issue either. And building the standalone folder on Linux, which works, and moving it to Windows and running it still causes the error.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Fix Terminal “Operation not permitted” Error in macOS ...
How to Fix “Operation not permitted” Error in Terminal for Mac OS · Pull down the Apple menu and choose 'System Preferences' ·...
Read more >
operation not permitted Mac Terminal - iBoysoft Data Recovery
When the Terminal says "Operation not permitted," it means you are not privileged to access the protected files and directories on your Mac....
Read more >
Mac Terminal Operation Not Permitted? Fixed Now - EaseUS
3 Ways to Fix Operation Not Permitted on Mac Terminal ; Select the Home Folder; Head into File, then click on "Get Into";...
Read more >
Terminal Says Operation not Permitted on Mac, Fix
Operation not Permitted error fix · 1. Open System Preferences and Security & Privacy. · 2. Click the Privacy tab. · 3. Click...
Read more >
What Is “Operation Not Permitted” Error On Mac? How To Fix It
Shut down your computer. · Hold Power and startup your system. · Release the hold only after you see the startup Options. ·...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found