English 中文(简体)
无法启动 pnpm 脚本 - 错误 : 命令失败, 退出代码 1
原标题:Can t start pnpm script - ERROR : Command failed with exit code 1
I m using pnpm to start my gulp script but it s been the second time I ve this error & I don t know how to fix it. I ve tried : Uninstall then reinstall node Same with pnpm, gulp-cli & gulp Deleting node_modules folder, then pnpm install Reinstall webpack, @babel/core, @babel/register Adding type: module to my package.json Here s the error message: ➜ sabir git:(master) ✗ pnpm start > sabir@1.0.0 start /Users/vianneybernet/Library/Mobile Documents/com~apple~CloudDocs/Sites/sabir > gulp [18:14:01] Requiring external module @babel/register /Users/vianneybernet/Library/Mobile Documents/com~apple~CloudDocs/Sites/sabir/gulpfile.babel.js:1 import { src, dest, watch, series, parallel } from gulp ; ^^^^^^ SyntaxError: Cannot use import statement outside a module at Module._compile (internal/modules/cjs/loader.js:895:18) at Module._compile (/Users/vianneybernet/Library/Mobile Documents/com~apple~CloudDocs/Sites/sabir/node_modules/.pnpm/registry.npmjs.org/pirates/4.0.1/node_modules/pirates/lib/index.js:99:24) at Module._extensions..js (internal/modules/cjs/loader.js:995:10) at Object.newLoader [as .js] (/Users/vianneybernet/Library/Mobile Documents/com~apple~CloudDocs/Sites/sabir/node_modules/.pnpm/registry.npmjs.org/pirates/4.0.1/node_modules/pirates/lib/index.js:104:7) at Module.load (internal/modules/cjs/loader.js:815:32) at Function.Module._load (internal/modules/cjs/loader.js:727:14) at Module.require (internal/modules/cjs/loader.js:852:19) at require (internal/modules/cjs/helpers.js:74:18) at execute (/Users/vianneybernet/Library/Mobile Documents/com~apple~CloudDocs/Sites/sabir/node_modules/.pnpm/registry.npmjs.org/gulp-cli/2.2.0/node_modules/gulp-cli/lib/versioned/^4.0.0/index.js:36:18) at Liftoff.handleArguments (/Users/vianneybernet/Library/Mobile Documents/com~apple~CloudDocs/Sites/sabir/node_modules/.pnpm/registry.npmjs.org/gulp-cli/2.2.0/node_modules/gulp-cli/index.js:201:24)  ERROR  Command failed with exit code 1. Here is my gulp script : import { src, dest, watch, series, parallel } from gulp ; import yargs from yargs ; import sass from gulp-sass ; import cleanCss from gulp-clean-css ; import gulpif from gulp-if ; import postcss from gulp-postcss ; import sourcemaps from gulp-sourcemaps ; import postcssPresetEnv from postcss-preset-env ; import autoprefixer from autoprefixer ; import tailwindcss from tailwindcss ; import atimport from postcss-import ; import del from del ; import webpack from webpack-stream ; import named from vinyl-named ; import browserSync from browser-sync ; // import imageOptim from gulp-imageoptim ; import imagemin from gulp-imagemin ; const PRODUCTION = yargs.argv.prod; const server = browserSync.create(); export const clean = () => del([ static ]); export const styles = () => { return src( src/scss/app.scss ) .pipe(gulpif(!PRODUCTION, sourcemaps.init())) .pipe(sass().on( error , sass.logError)) .pipe( postcss([atimport(), tailwindcss( ./tailwind.config.js ), postcssPresetEnv({ stage: 1 })]) ) .pipe(gulpif(PRODUCTION, postcss([autoprefixer]))) .pipe(gulpif(PRODUCTION, cleanCss({ compatibility: ie8 }))) .pipe(gulpif(!PRODUCTION, sourcemaps.write())) .pipe(dest( static/css )) .pipe(server.stream()); }; export const images = () => { return src([ src/images/*.{jpg,jpeg,png,svg,gif} , src/images/**/*.{jpg,jpeg,png,svg,gif} ]) .pipe(gulpif(PRODUCTION, imagemin())) .pipe(dest( static/images )); }; export const copy = () => { return src([ src/**/* , !src/{images,js,scss,css} , !src/{images,js,scss,css}/**/* ]).pipe( dest( static ) ); }; export const scripts = () => { return src( src/js/bundle.js ) .pipe(named()) .pipe( webpack({ module: { rules: [ { test: /.js$/, use: { loader: babel-loader , options: { presets: [] } } } ] }, mode: PRODUCTION ? production : development , devtool: !PRODUCTION ? inline-source-map : false, output: { filename: [name].js }, externals: { jquery: jQuery } }) ) .pipe(dest( static/js )); }; export const watchForChanges = () => { watch( src/scss/**/*.scss , styles); watch( src/images/**/*.{jpg,jpeg,png,svg,gif} , series(images)); watch([ src/**/* , !src/{images,js,scss} , !src/{images,js,scss}/**/* ], series(copy)); watch( src/js/**/*.js , series(scripts)); }; export const dev = series(clean, parallel(styles, images, copy, scripts), watchForChanges); export const build = series(clean, parallel(styles, images, copy, scripts)); export default dev; Thanks for helping!
问题回答
I just noticed that the .babelrc was deleted, it was including : { "presets": ["@babel/preset-env"] }




相关问题
How to make Sequelize use singular table names

I have an model called User but Sequelize looks for the table USERS whenever I am trying to save in the DB. Does anyone know how to set Sequelize to use singular table names? Thanks.

What is Node.js? [closed]

I don t fully get what Node.js is all about. Maybe it s because I am mainly a web based business application developer. What is it and what is the use of it? My understanding so far is that: The ...

Clientside going serverside with node.js

I`ve been looking for a serverside language for some time, and python got my attention somewhat. But as I already know and love javascript, I now want learn to code on the server with js and node.js. ...

Can I use jQuery with Node.js?

Is it possible to use jQuery selectors/DOM manipulation on the server-side using Node.js?

How do I escape a string for a shell command in node?

In nodejs, the only way to execute external commands is via sys.exec(cmd). I d like to call an external command and give it data via stdin. In nodejs there does yet not appear to be a way to open a ...

热门标签